feat(trading-signals): add signals to trend, channel and volume indicators - #1394
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Keltner and Alligator boundary semantics lack mutation-resistant equality coverage.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds directional signals to eleven trend, channel, and volume indicators while making signal history replacement-safe.
Changes:
- Adds bullish, bearish, and sideways signal calculations.
- Evaluates and caches signals when results are produced.
- Adds signal-state, replacement, and rollback tests.
| File | Description |
|---|---|
base/Indicator.ts |
Caches signal history with results. |
base/Indicator.test.ts |
Tests signal timing and rollback. |
trend/ALLIGATOR/Alligator.ts |
Adds line-order signals. |
trend/ALLIGATOR/Alligator.test.ts |
Tests Alligator signals. |
trend/AROON/Aroon.ts |
Adds Aroon comparison signals. |
trend/AROON/Aroon.test.ts |
Tests Aroon signals. |
trend/HT/HTTrendline.ts |
Compares price with trendline. |
trend/HT/HTTrendline.test.ts |
Tests trendline signals. |
trend/ICHIMOKU/IchimokuCloud.ts |
Compares conversion and base lines. |
trend/ICHIMOKU/IchimokuCloud.test.ts |
Tests Ichimoku signals. |
trend/LINREG/LinearRegression.ts |
Derives signals from slope. |
trend/LINREG/LinearRegression.test.ts |
Tests slope signals. |
trend/PSAR/PSAR.ts |
Exposes PSAR direction. |
trend/PSAR/PSAR.test.ts |
Tests PSAR signals. |
trend/SUPERTREND/SuperTrend.ts |
Exposes SuperTrend direction. |
trend/SUPERTREND/SuperTrend.test.ts |
Tests SuperTrend signals. |
trend/VSTOP/VolatilityStop.ts |
Exposes stop direction. |
trend/VSTOP/VolatilityStop.test.ts |
Tests stop signals. |
trend/VWAP/VWAP.ts |
Compares close with VWAP. |
trend/VWAP/VWAP.test.ts |
Tests VWAP signals. |
volatility/DC/DonchianChannels.ts |
Adds channel-breakout signals. |
volatility/DC/DonchianChannels.test.ts |
Tests Donchian signals. |
volatility/KC/KeltnerChannels.ts |
Adds channel-boundary signals. |
volatility/KC/KeltnerChannels.test.ts |
Tests Keltner signals. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
getSignal()to indicators that have a well-known directional reading but did not expose one.SuperTrendtrendtrendVolatilityStopsignalsignalPSARAroonIchimokuCloudLinearRegressionAlligatorKeltnerChannelsDonchianChannelsVWAPHTTrendlineThe
Alligatordocs used to say it emits no signal; they now describe the reading instead.Signals are judged when a result is set
Most of these readings compare a result with the price of its bar (Keltner, Donchian, VWAP, HTTrendline) or with internal state (PSAR's direction). The signal base classes could not support that: they evaluated the signal lazily from a result value, and evaluated the previous result for
hasChangedat a moment when the indicator already held the next bar. That is why Bollinger Bands, Acceleration Bands and Gann HiLo each hand-roll their own price and result history.TrendIndicatorSeriesandTrendIndicatornow evaluate the signal once, when a result is set, and keep that state together with the one before it. A replacement keeps the state of the bar before the replaced one, androllbackLastResult()rolls the signal back too. Existing signals keep their behavior, because they either depend on the result alone or update their internals before setting the result. Tests inIndicator.test.tspin the new timing and fail against the old base classes. Bollinger Bands, Acceleration Bands and Gann HiLo could move onto the base classes in a follow-up.Not included
SwingIndex,AccumulativeSwingIndex,WAD,ChandelierExitandChandeKrollStopstay without a signal. Their docs explain why on purpose: the Swing Index is noisy on its own, the ASI is read with drawn trendlines, WAD is read for divergence, and which stop matters depends on the trade the caller holds.NVIandPVIstay without one too, because they are read against a long moving average of themselves that would need its own setting.Behavior changes
Results are unchanged. The indicators above now have
getSignal(), so the CLI prints a signal for them.SuperTrend,VolatilityStop,Aroon,IchimokuCloud,LinearRegression,Alligator,KeltnerChannelsandDonchianChannelsextendTrendIndicatorinstead ofTechnicalIndicator, andPSAR,VWAPandHTTrendlineextendTrendIndicatorSeriesinstead ofIndicatorSeries.