CCI Strong Breakthrough Strategy
This strategy is based on the classic Commodity Channel Index (CCI) and only goes long. It enters the market when the CCI indicator is at an extremely low level (CCI <-150 or user-defined threshold) and regains…

Overview
This strategy is based on the classic Commodity Channel Index (CCI) and only goes long. It enters the market when the CCI indicator is at an extremely low level (CCI <-150 or user-defined threshold) and regains strength (i.e. CCI> CCI of previous candle), with a filter on the "strength" of the prices themselves (i.e. the closing of the signal bar must be higher than a certain difference - fixed at 0.25% - from the opening).
The strategy exits when either the stop loss is triggered or prices rise above the CCI upper band.
The goal is to achieve a high percentage of profitable trades (well over 50%) rather than capturing the full duration of a trend. It is therefore suitable for those who "hate to see potential losses".
Strategy Logic
Construct CCI indicator and bands using ta.sma() and ta.dev() functions.
Use input to select start date for backtest.
Entry signal: CCI crosses below lower band and starts increasing. Additional filter requires close > open by 0.25%.
Exit 1: CCI rises above upper band, take profit.
Exit 2: Price drops below stop loss level, cut losses.
Strategy only goes long based on CCI strength, with stops to control risk.
Advantage Analysis
The strategy has the following advantages:
Identify overbought/oversold with CCI to capitalize on reversals.
Only long direction avoids excessive risk from bad trades.
Price strength filter ensures support formed before entry.
Stop loss mechanism limits per trade loss and manages capital.
Flexible backtest parameters to adjust entry filters.
High win rate suits investors focused on risk management.
Clear logic and simple implementation.
Risk Analysis
There are also some risks:
Going only long may miss short-term downtrends.
Poor CCI parameter tuning leads to failure.
Stop loss too loose fails to limit losses.
Strong uptrend blows through stops causing large losses.
High trade frequency increases transaction costs.
Possible solutions:
Optimize CCI parameters to find best values.
Adjust stop loss to balance risk and slippage.
Manage entry frequency considering costs.
Combine with trend and range filters.
Enhancement Opportunities
Some ways to improve the strategy:
Implement dynamic stops based on market volatility.
Add filters like MACD to avoid stops being too wide.
Incorporate short side when CCI overheats.
Consider costs, set minimum profit target.
Optimize parameters for time frame.
Machine learning for automated parameter tuning.
Add position sizing for dynamic allocation.
Conclusion
In summary, this long-only strategy capitalizes on CCI overbought/oversold levels with price strength filter and stop losses. It offers easy implementation, good risk control and high win percentage. The limitations of being long-only and fixed stops can be addressed through parameter optimization, short entries, dynamic stops etc. The strategy suits investors seeking high win rates and proper risk management.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1_close | 0 | src: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_int_1 | 20 | Period |
| v_input_float_1 | 8 | Stop Loss percentage |
| v_input_float_2 | 0.25 | Close of the signal bar higher than Open % |
| v_input_int_2 | 150 | Upper Band |
| v_input_int_3 | -150 | Low Band |
| v_input_int_4 | true | From Month |
| v_input_int_5 | true | From Day |
| v_input_int_6 | 2016 | From Year |
| v_input_int_7 | true | Thru Month |
| v_input_int_8 | true | Thru Day |
| v_input_int_9 | 2112 | Thru Year |
Source Pine Script
/*backtest
start: 2022-11-08 00:00:00
end: 2023-11-14 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title='CCI High Performance long only', overlay=false )
src = input(close)
length = input.int(20, title='Period', minval=1)
lossp = input.float(8, title='Stop Loss percentage', minval=0.5, step=0.5)
scart = input.float(0.25, title='Close of the signal bar higher than Open %', minval = 0)
upperline = input.int(150, title='Upper Band', minval=0, step=10)
lowline = input.int(-150, title='Low Band', maxval=0, step=10)
// construction of CCI (not on close but in totalprice) and of bands
ma = ta.sma(src, length)
cci = (src - ma) / (0.015 * ta.dev(src, length))
plot(cci, 'CCI', color=color.new(#996A15, 0))
band1 = hline(upperline, 'Upper Band', color=#C0C0C0, linestyle=hline.style_dashed)
band0 = hline(lowline, 'Lower Band', color=#C0C0C0, linestyle=hline.style_dashed)
fill(band1, band0, color=color.new(#9C6E1B, 90), title='Background')
// === INPUT BACKTEST RANGE ===
fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromYear = input.int(defval = 2016, title = "From Year", minval = 1970)
thruMonth = input.int(defval = 1, title = "Thru Month", minval = 1, maxval = 12)
thruDay = input.int(defval = 1, title = "Thru Day", minval = 1, maxval = 31)
thruYear = input.int(defval = 2112, title = "Thru Year", minval = 1970)
// === FUNCTION EXAMPLE limit for backtest ===
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function "within window of time"
//ENTRY CONDITIONS
// strategy: enter when CCI is under the low line and starts increasing. The filter is that the signal candle should mark a close higher than a x-percent
// (0.25%) of the open
// Exit when either when it reaches the target of a prices highest than high level of CCI or fixed stop loss (in percentage)
scart_level = open * (1+scart/100)
entryl = cci[1] < lowline[1] and cci > cci[1] and close > scart_level and window()
exit1 = cci> upperline
strategy.entry('Long', strategy.long, when=entryl)
strategy.close('Long', when=exit1, comment='target')
// money management (only stop loss)
losspel = strategy.position_avg_price * (1 - lossp / 100)
fixed_stop_long = close < losspel
strategy.close('Long', when=fixed_stop_long, comment='Stop Loss')
Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-15. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/CCI-Strong-Breakthrough-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- MACD Bollinger Turtle Trading StrategyPine Script · Breakout · 1d
- Quantitative Trading Strategy with Multiple FactorsPine Script · Breakout · 1d
- Adaptive Trading Strategy Based on ADX IndicatorPine Script · Breakout · 1d
- Average Line Breakthrough StrategyPine Script · Breakout · 1d
- Bollinger Bands Dynamic Breakout StrategyPine Script · Breakout · 1h
- Bull Flag Breakout StrategyPine Script · Breakout · 1h