CCI Surge - Momentum Continuation Strateg — Strategy by wielkieef

By wielkieef

Performance Metrics

Description

A trend-following strategy for the 4H timeframe that uses extreme CCI readings as breakout confirmations rather than reversal signals, combined with HMA slope as a trend filter, an ATR-based hard stop, and a percentage-based trailing exit.CONCEPTMost CCI-based strategies treat extreme readings as mean-reversion signals: sell when CCI crosses above +100, buy when it drops below -100. This works in ranging markets but fails consistently in trending ones, where CCI can stay above +100 for many consecutive bars while price keeps climbing. The same applies symmetrically to short side in downtrends.This strategy inverts that logic. A CCI breakout above +100 is treated as momentum confirmation — entering long when most mean-reversion strategies would exit. The same applies to shorts on CCI below -100. The reasoning is straightforward: extreme CCI in the direction of an established trend is not exhaustion, it is acceleration. Fading these readings produces consistent losses in trending markets.To filter out fake breakouts in choppy or transitioning markets, the strategy requires HMA(80) slope confirmation on the same bar — HMA must be rising and price above HMA for longs, opposite for shorts.ENTRY LOGICThe core entry condition combines three filters that must all align on the same bar:Pine Script®cci = ta.cci(close, cciLen)hma = ta.hma(close, hmaLen)hmaUp = hma > hma[1] and close > hmahmaDn = hma cciHigh and hmaUp and gateLong and not inPositionshortSignal = cci = cciLow gateShort := trueif strategy.position_size[1] != 0 and strategy.position_size == 0 gateLong := false gateShort := falseExpand 4 linesThe logic is subtle but important: when a position closes, both gates flip to false. They flip back to true only when CCI returns through the threshold from outside. This guarantees each new trade represents a genuinely new momentum event, not a continuation of the previous one. This single mechanism eliminates a large portion of redundant losing trades that plague typical breakout strategies.EXIT STRUCTURETwo independent exit layers operate simultaneously:1. Hard ATR Stop (ATR 14 × 2.0)Pine Script®atrSL_long = entryPrice - atrValue * atrMultiplieratrSL_short = entryPrice + atrValue * atrMultiplierCatastrophic protection from the first bar onward. Volatility-adjusted, so wider stops in active markets and tighter in quiet ones. Triggers if price moves against the position by 2 ATR before profit develops. This protects against gap moves and fast reversals during the early bars where the trailing has not yet engaged with meaningful price action.2. Percentage Trailing Stop (6% of entry price)Pine Script®trail_offset = strategy.position_avg_price * trailingStopPct / 100strategy.exit("Trailing TP", from_entry="Long", trail_points=trail_offset, trail_offset=trail_offset)Engages from the bar following entry. The 6% width is intentionally loose for 4H crypto — tighter trailing gets whipsawed by normal volatility, looser trailing gives back too much profit. Calculated as a fixed percentage of entry price (not ATR-based or chandelier), which means as the position moves into deeper profit, the trailing distance becomes proportionally tighter relative to current price. This was tested against ATR-based and chandelier alternatives — percentage-of-entry produced significantly better results in this specific setup.The two layers operate independently and protect different scenarios. The ATR stop catches catastrophic moves in the early bars before the trade develops. The trailing locks in profits as the trade matures and prevents reversals from giving back accumulated gains.DEFAULTS AND TUNINGDefaults are tuned for BTCUSDT 4H and represent a balance point — they are not optimization peaks. The strategy was validated across multiple instruments without per-asset re-optimization to avoid overfitting:CCI Length: 14CCI Thresholds: +100 / -100 (classical CCI levels)HMA Length: 80 (~13 days on 4H)ATR Length: 14ATR Multiplier: 2.0Trailing Stop: 6%Position sizing: 75% of equity (for backtest visibility)Commission: 0.03% per side (Binance futures level)Slippage: 0 ticksFor lower timeframes (1H): tighten CCI thresholds to ±150 to compensate for noise. Trailing can be reduced to 4-5%.For higher timeframes (1D): defaults work but signal frequency drops significantly. Consider widening ATR multiplier to 2.5 since daily swings are larger.Not recommended for 15M or below: CCI breakouts on low timeframes are dominated by noise.For non-crypto assets: trailing percentage and ATR multiplier need re-validation. Forex pairs typically want tighter trailing (3-4%) and lower ATR multiplier (1.5×). Stocks behave differently across sectors — backtest before live use.WHAT TO WATCH OUT FORRanging markets are the weakness. In extended ranging periods where CCI oscillates between ±100 without directional follow-through, the strategy will produce small breakeven or losing trades. The HMA filter mitigates this but does not eliminate it. Backtests show occasional 10-15 trade flat periods during major consolidations such as the 2022-2023 BTC range.Trailing gives back profit by design. The 6% trailing structure means you will always give back approximately 6% from peak before exit. This is the deliberate cost of staying in winning trends. Tightening it produces more whipsaws than additional profit.Asset-specific volatility matters. Best on high-volatility crypto majors. On low-volume pairs the ATR stop can be too wide relative to typical move size.Commission settings matter. Default 0.03% reflects Binance futures fees. Spot trading with 0.1% fees will reduce net performance — adjust and re-test.No repaint. All signals trigger on bar close. Entries and exits are deterministic.VISUALIZATIONThe script provides extensive on-chart visualization to help analyze each trade:Blue triangles below bars mark long entriesRed triangles above bars mark short entriesTP labels (red triangle for long-profit, green for short-profit) appear above/below the closing barSL labels (magenta xcross) mark stop-loss exitsMagenta cross at exact exit price marks every trade closureCCI-based bar coloring (green when CCI > 0, red when CCI < 0) for visual context — toggleableHMA line and ATR SL levels — toggleable in Visualization settingsPosition background tinting (green during longs, red during shorts) — toggleableAll visual elements can be toggled independently in the input settings.ORIGINALITYThe script combines well-known indicators (CCI, HMA, ATR) but the inverted CCI logic combined with the momentum reset gate is the original contribution. This is not a repackaging of existing public scripts — both the entry logic inversion and the reset gate were developed and validated through extensive backtesting across multiple instruments and timeframes.The custom percentage-based trailing (calculated as percentage of entry price) was also tested against alternatives (ATR-based trailing, chandelier exit, fixed-pip trailing) and produced significantly better results in this specific setup. This is a deliberate design choice, not a default — and it matters for the strategy's behavior in deep-profit scenarios.DISCLAIMERThis strategy is published for educational and research purposes. It is not financial advice and no profitability guarantee is implied. Past performance in backtests does not guarantee future results. Always forward-test on a paper account before risking real capital. Adjust parameters based on your individual risk tolerance, asset class, and trading style.Open source under Mozilla Public License 2.0 — read the code, fork it, improve it. Constructive feedback welcome in the comments.Check my profile for other published scripts.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView