This strategy is a momentum trading system based on the Commodity Channel Index (CCI), designed to capture trading opportunities in oversold areas by monitoring price deviations from the mean. The strategy uses a 12-period lookback, enters long positions when CCI drops below -90 threshold, exits when closing price breaks above previous highs, and includes optional stop-loss and take-profit mechanisms.
The core principle utilizes CCI to measure price deviation from its mean. CCI calculation involves: first computing typical price (arithmetic mean of high, low and close prices), then calculating Simple Moving Average (SMA) of typical price, finally deriving CCI by subtracting SMA from typical price, dividing by mean deviation and multiplying by 0.015. Long positions are entered when CCI falls below -90, indicating possible oversold conditions; positions are closed when price breaks above previous highs, confirming upward trend. The strategy offers customizable stop-loss and take-profit parameters to accommodate different risk preferences.
This strategy captures market oversold opportunities through CCI indicator, combined with stop-loss and take-profit mechanisms to create a complete trading system. The strategy features clear logic, easy execution, and good risk control capabilities. Through optimization measures like signal filtering and dynamic thresholds, the strategy’s stability and profitability can be further improved. Traders are advised to conduct thorough backtesting and adjust parameters according to specific market characteristics before live implementation.
/*backtest start: 2019-12-23 08:00:00 end: 2024-11-27 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("CCI Threshold Strategy", overlay=false, initial_capital=50000, pyramiding=0, commission_type=strategy.commission.cash_per_contract, commission_value=0.05, slippage=1) // --- Input Parameters --- // Lookback period for CCI calculation lookbackPeriod = input.int(12, minval=1, title="CCI Lookback Period") // Buy threshold for CCI; typically represents an oversold condition buyThreshold = input.int(-90, title="CCI Buy Threshold") // Stop loss and take profit settings stopLoss = input.float(100.0, minval=0.0, title="Stop Loss in Points") takeProfit = input.float(150.0, minval=0.0, title="Take Profit in Points") // Checkboxes to enable/disable SL and TP useStopLoss = input.bool(false, title="Enable Stop Loss") useTakeProfit = input.bool(false, title="Enable Take Profit") // --- Calculate CCI --- // CCI (Commodity Channel Index) is used as a momentum indicator to identify oversold and overbought conditions cci = ta.cci(close, length=lookbackPeriod) // --- Define Buy and Sell Conditions --- // Buy condition: CCI drops below -90, indicating potential oversold levels longCondition = cci < buyThreshold // Sell condition: Close price crosses above the previous day's high, signaling potential exit sellCondition = close > ta.highest(close[1], 1) // --- Strategy Execution --- // Buy entry based on the long condition if (longCondition) strategy.entry("Buy", strategy.long) // Close the long position based on the sell condition if (sellCondition) strategy.close("Buy") // Optional: Add stop loss and take profit for risk management if (longCondition) strategy.exit("Sell", from_entry="Buy", loss=useStopLoss ? stopLoss : na, profit=useTakeProfit ? takeProfit : na) // --- Plotting for Visualization --- // Plot CCI with threshold levels for better visualization plot(cci, title="CCI", color=color.blue) hline(buyThreshold, "Buy Threshold", color=color.red, linestyle=hline.style_dotted) hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)