Strategy vault / Mean reversion
4 Hour CCI Reversal Strategy
This is a reversal trading strategy based on the CCI indicator. It will open reverse trades when the CCI indicator shows overbought or oversold levels. Overall, this strategy utilizes the overbought and oversold…
Overview
This is a reversal trading strategy based on the CCI indicator. It will open reverse trades when the CCI indicator shows overbought or oversold levels. Overall, this strategy utilizes the overbought and oversold features of the CCI indicator to capture price reversal opportunities.
Strategy Logic
Firstly, this strategy is based on the CCI indicator. The CCI indicator formula is:
CCI = (Typical Price - Simple Moving Average) / (0.015 * Standard Deviation)
Where,
Typical Price = (Highest + Lowest + Close) / 3
Simple Moving Average = Moving average of Typical Price over past N days
Standard Deviation = Square root of variance of Typical Price over past N days
This strategy uses a 11-period CCI indicator. And -150 is set as the oversold level, while 150 as the overbought level.
On every bar close, the 11-period CCI indicator will be checked. If CCI crosses below -150, a long signal is generated. If CCI crosses above 150, a short signal is generated.
After receiving the signal, market order will be used to open position. 1% profit target and 0.5% stop loss are set.
Advantage Analysis
- Using CCI indicator can effectively capture price reversal opportunities
- CCI parameters are adjustable for optimization
- Fixed profit target and stop loss ratio effectively controls risk
- Simple and clear strategy logic, easy to understand and implement
Risk Analysis
- CCI indicator may generate lots of false signals, entry signals may not be reliable
- Solution: Optimize CCI parameters, add filter with other indicators
- Fixed profit target and stop loss ratio may not suit different products
- Solution: Add dynamic profit target and stop loss
- Strategy relies solely on CCI, risk of ineffectiveness is high
- Solution: Combine multiple indicators to improve robustness
- No consideration on trading cost, live performance may suffer
- Solution: Add slippage control, reduce trading frequency
Optimization Directions
- Optimize CCI parameters to find better parameter combinations
- Add other indicators like MACD, KDJ for signal filtering
- Develop dynamic profit target and stop loss instead of fixed ratio
- Optimize strategy to lower trading frequency, reducing trading cost impact
- Conduct backtesting optimization to find best parameter combination for live trading
Summary
The 4-hour CCI reversal strategy is a simple strategy utilizing CCI indicator for reversal trading. It has the advantage of clear logic and easy implementation. But it also has weaknesses like unreliable CCI signals and inflexible profit target/stop loss. Further improvements can be made by optimizing CCI parameters, adding filter indicators, developing dynamic exits, etc. Overall this strategy provides a CCI-based idea for quantitative trading, but requires further optimization before live application.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 11 | length |
| v_input_2 | -150 | overSold |
| v_input_3 | 150 | overBought |
| v_input_4 | 15 | Timeframe |
| v_input_5 | 16 | Length |
Source Pine Script
/*backtest
start: 2023-09-12 00:00:00
end: 2023-10-12 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("4H CCI Strategy", overlay=true)
length = input( 11 )
overSold = input( -150 )
overBought = input( +150 )
price1 = high
price2 = low
ucci = cci(price1, length)
dcci = cci(price2, length)
vcci = cci(ohlc4, 11)
resCustom = input(title="Timeframe", defval="15")
Length = input(16, minval=1)
xPrice = request.security(syminfo.tickerid, resCustom, hlc3)
xvnoise = abs(xPrice - xPrice[1])
nfastend = 0.666
nslowend = 0.0645
nsignal = abs(xPrice - xPrice[Length])
nnoise = sum(xvnoise, Length)
nefratio = iff(nnoise != 0, nsignal / nnoise, 0)
nsmooth = pow(nefratio * (nfastend - nslowend) + nslowend, 2)
nAMA = nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1]))
basis1 = nAMA
slope = change(basis1,1)
if (not na(vcci))
if (crossover(dcci, overSold))
strategy.entry("CCILE", strategy.long, comment="CCILE")
strategy.exit("exit", "CCILE", profit = 0.01, loss = 0.005)
if (crossunder(ucci, overBought))
strategy.entry("CCISE", strategy.short, comment="CCISE")
strategy.exit("exit", "CCISE", profit = 0.01, loss = 0.005)
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-13. 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/4-Hour-CCI-Reversal-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
- Multi Indicator Scoring Trading StrategyPine Script · Mean reversion · 1d
- MACD RSI and EMA StrategyPine Script · Mean reversion · 1d
- RSI amp CCI Combination Quantitative Trading StrategyPine Script · Mean reversion · 1h
- A Momentum Tracking Mean Reversion StrategyPine Script · Mean reversion · 1h
- Dual MACD Reversal Trading StrategyPine Script · Mean reversion · 1d
- 3 10 Oscillator Profile Flagging StrategyPine Script · Mean reversion · 1d