Skip to content

feat(trading-signals): add signals to trend, channel and volume indicators - #1394

Merged
bennycode merged 3 commits into
mainfrom
feat/indicator-signals
Oct 1, 2026
Merged

bennycode merged 3 commits into
mainfrom
feat/indicator-signals

Conversation

@bennycode

@bennycode bennycode commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Adds getSignal() to indicators that have a well-known directional reading but did not expose one.

Indicator BULLISH BEARISH SIDEWAYS
SuperTrend its own trend its own trend –
VolatilityStop its own signal its own signal –
PSAR dots below price (long) dots above price (short) –
Aroon Up above Down Down above Up equal
IchimokuCloud conversion above base conversion below base equal
LinearRegression positive slope negative slope flat
Alligator lips > teeth > jaw lips < teeth < jaw lines intertwined
KeltnerChannels close above the upper line close below the lower line inside
DonchianChannels candle sets the channel high candle sets the channel low both or neither
VWAP close above VWAP close below VWAP equal
HTTrendline price above the trendline price below the trendline equal

The Alligator docs 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 hasChanged at 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.

TrendIndicatorSeries and TrendIndicator now 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, and rollbackLastResult() 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 in Indicator.test.ts pin 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, ChandelierExit and ChandeKrollStop stay 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. NVI and PVI stay 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, KeltnerChannels and DonchianChannels extend TrendIndicator instead of TechnicalIndicator, and PSAR, VWAP and HTTrendline extend TrendIndicatorSeries instead of IndicatorSeries.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Keltner and Alligator boundary semantics lack mutation-resistant equality coverage.

Review effort: Balanced
Findings: 2 Medium severity

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.

Comment thread packages/trading-signals/src/trend/ALLIGATOR/Alligator.ts
Comment thread packages/trading-signals/src/volatility/KC/KeltnerChannels.test.ts
@bennycode
bennycode merged commit 4997c52 into main Oct 1, 2026
11 checks passed
@bennycode
bennycode deleted the feat/indicator-signals branch October 1, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants