AdaptiveTrendChannel
AdaptiveTrendChannel is a built-in TypeScript strategy from @tradejs/strategies.
It replays candles through an adaptive channel engine, watches for bullish/bearish channel flips, and sizes entries from the distance to the channel boundary used as the stop.
Entry Logic
- Builds runtime state with
createAdaptiveTrendChannelEngine({ initialCandles, config }). - On each candle, reads
runtimeState.signalandruntimeState.snapshot. - Skips until a channel flip signal exists.
- Selects
LONGorSHORTside config from the signal direction. - Applies context filters through
getAdaptiveTrendChannelFilterSkipCode(...). - Uses the signal floor/roof as stop-loss:
- long stop:
signal.floor - short stop:
signal.roof
- long stop:
- Computes target from
ADAPTIVE_TREND_CHANNEL_TARGET_R_MULT. - Sizes quantity from
MAX_LOSS_VALUE / riskDistance, withFEE_PERCENTbuffer. - Returns
entrywith channel figures andadaptiveTrendChannelContext.
Entry codes:
ADAPTIVE_TREND_CHANNEL_BULLISH_FLIPADAPTIVE_TREND_CHANNEL_BEARISH_FLIP
Exits
When a position exists:
ADAPTIVE_TREND_CHANNEL_BREAK_EXITwhenADAPTIVE_TREND_CHANNEL_EXIT_ON_CHANNEL_BREAK=trueand price breaks the active channel boundary.ADAPTIVE_TREND_CHANNEL_OPPOSITE_FLIP_EXITwhenADAPTIVE_TREND_CHANNEL_EXIT_ON_OPPOSITE_FLIP=trueand the engine emits the opposite flip.- otherwise
POSITION_EXISTS.
Config Parameters
Shared runtime:
ENV,INTERVAL,MAKE_ORDERS,CLOSE_OPPOSITE_POSITIONSBACKTEST_PRICE_MODEAI_ENABLED,AI_MODE,MIN_AI_QUALITYML_ENABLED,ML_THRESHOLD
Risk and shared indicators:
FEE_PERCENT,MAX_LOSS_VALUEMA_FAST,MA_MEDIUM,MA_SLOWOBV_SMA,ATR,ATR_PCT_SHORT,ATR_PCT_LONGBB,BB_STD,MACD_FAST,MACD_SLOW,MACD_SIGNAL
Channel model:
ADAPTIVE_TREND_CHANNEL_REGRESSION_BARSADAPTIVE_TREND_CHANNEL_ENVELOPE_BARSADAPTIVE_TREND_CHANNEL_ATR_STRETCHADAPTIVE_TREND_CHANNEL_VOLATILITY_LOOKBACKADAPTIVE_TREND_CHANNEL_TARGET_R_MULTADAPTIVE_TREND_CHANNEL_MIN_BREAKOUT_DISTANCE_PCTADAPTIVE_TREND_CHANNEL_MAX_BREAKOUT_DISTANCE_PCTADAPTIVE_TREND_CHANNEL_MIN_CHANNEL_WIDTH_PCTADAPTIVE_TREND_CHANNEL_MAX_CHANNEL_WIDTH_PCTADAPTIVE_TREND_CHANNEL_MIN_VOLUME_REL20ADAPTIVE_TREND_CHANNEL_REQUIRE_CONTEXT_ALIGNMENTADAPTIVE_TREND_CHANNEL_EXIT_ON_OPPOSITE_FLIPADAPTIVE_TREND_CHANNEL_EXIT_ON_CHANNEL_BREAKADAPTIVE_TREND_CHANNEL_MAX_FIGURE_POINTS
Side configs:
LONG.enable,LONG.direction,LONG.minRiskRatioSHORT.enable,SHORT.direction,SHORT.minRiskRatio
Signal Payload
The strategy stores:
additionalIndicators.adaptiveTrendChannelContext- channel figures from
buildAdaptiveTrendChannelFigures(...) orderPlan.qtyorderPlan.stopLossPrice- one take-profit at the computed target price
Common Skip Reasons
NO_ADAPTIVE_TREND_CHANNEL_FLIPDEV_TRADE_COOLDOWNSTRATEGY_DISABLED- filter-specific skip code from
getAdaptiveTrendChannelFilterSkipCode(...) INVALID_STOPINVALID_QTYRISK_RATIO:<value>
Validation Notes
Inspect the generated channel figures before comparing metrics. This strategy depends on structural channel state, so data gaps and warmup length can change early signals.