TrendShift
TrendShift trades transitions detected as bullish or bearish flips in a
dynamic trend band.
Visual overview
The illustrations are schematic, not market data. Exact thresholds, confirmation rules, and risk parameters come from the active strategy config.
Entry Logic
- Replays candles through
createTrendShiftEngine(...). - Reads
runtimeState.signalandruntimeState.snapshot. - Skips until a bullish or bearish flip exists.
- Applies volatility and strategy guardrails.
- Selects
LONGorSHORTside config from signal direction. - Places the stop beyond the current band with ATR and percent buffers.
- Computes target from
TRENDSHIFT_TARGET_R_MULT. - Sizes quantity from
MAX_LOSS_VALUE / riskDistance, using theRISK_FEE_RATE,RISK_SLIPPAGE_BPS, andRISK_MARKET_IMPACT_BPSestimates. - Returns
entrywith trend-shift figures andtrendShiftContext.
Entry codes:
TRENDSHIFT_BULLISH_FLIPTRENDSHIFT_BEARISH_FLIP
Exits
When a position exists:
TRENDSHIFT_OPPOSITE_FLIP_EXITwhenTRENDSHIFT_EXIT_ON_OPPOSITE_FLIP=trueand the engine emits the opposite flip.- otherwise
POSITION_EXISTS.
Configuration keys
The keys are grouped by purpose. A listed _LONG or _SHORT key overrides
the unsuffixed value for that direction.
| Group | Keys | Purpose |
|---|---|---|
| Runtime and decision services | ENV, INTERVAL, MAKE_ORDERS, CLOSE_OPPOSITE_POSITIONS, BACKTEST_PRICE_MODE, AI_ENABLED, AI_MODE, MIN_AI_QUALITY, ML_ENABLED, ML_THRESHOLD | Select the runtime mode and candle interval, control order placement, and enable optional AI or ML decisions. |
| Shared indicators | MA_FAST, MA_MEDIUM, MA_SLOW, OBV_SMA, ATR, ATR_PCT_SHORT, ATR_PCT_LONG, BB, BB_STD, MACD_FAST, MACD_SLOW, MACD_SIGNAL | Set the periods used to build shared market context and signal filters. |
| Trend band | TRENDSHIFT_MULTIPLICATIVE_FACTOR, TRENDSHIFT_SLOPE, TRENDSHIFT_ATR_LENGTH, TRENDSHIFT_WIDTH_PCT | Set the dynamic band response, slope, ATR period, and width. |
| Entry quality | TRENDSHIFT_CONFIRM_FLIP_WITH_CLOSE, TRENDSHIFT_MIN_FLIP_DISTANCE_ATR, TRENDSHIFT_MIN_SIGNAL_BODY_STRENGTH, TRENDSHIFT_MIN_ADX | Require close confirmation and set distance, candle-body, and trend-strength floors. |
| Target, stop, and exit | TRENDSHIFT_STOP_ATR_BUFFER_MULT, TRENDSHIFT_STOP_BUFFER_PCT, TRENDSHIFT_TARGET_R_MULT, TRENDSHIFT_TARGET_R_MULT_LONG, TRENDSHIFT_TARGET_R_MULT_SHORT, TRENDSHIFT_EXIT_ON_OPPOSITE_FLIP, TRENDSHIFT_OPPOSITE_EXIT_CONFIRMATION_BARS | Set stop and directional target distances and configure a confirmed opposite-flip exit. |
| Figures and side policy | TRENDSHIFT_MAX_FIGURE_POINTS, MAX_LOSS_VALUE, LONG.*, SHORT.* | Limit chart output, set the loss budget, and configure each direction. |
Signal Payload
The strategy stores:
additionalIndicators.trendShiftContext- band, flip, stop, and target figures from
buildTrendShiftFigures(...) orderPlan.stopLossPrice- one take-profit at the computed target
Common Skip Reasons
WAIT_DATANO_SIGNALPOSITION_EXISTSVERY_VOLATILITY- guardrail skip code from
getTrendShiftGuardrailSkipCode(...) DEV_TRADE_COOLDOWNSTRATEGY_DISABLEDINVALID_STOPINVALID_QTYRISK_RATIO:<value>
Validation Notes
Revalidate after changing market context, timeframe, or risk settings. Trend-transition systems are vulnerable to overfitting because small band and confirmation changes can move flips across candles.
Related: