
Die Strategie ist ein dynamisches Handelssystem, das auf dem Commodity Channel Indicator (CCI) basiert, um Handelschancen in überverkauften Bereichen des Marktes zu erfassen, indem es die Abweichung der Preise vom Durchschnittswert überwacht. Die Strategie verwendet 12 Zyklen als Rücklaufphase.
Der Kern der Strategie besteht darin, die Abweichung zwischen dem Preis und seinem Mittelwert anhand des CCI-Indikators zu messen. Der CCI-Berechnungsvorgang umfasst: Zuerst berechnet man den typischen Preis (die arithmetischen Mittelwerte für Höchst-, Tiefst- und Schlusskosten), dann berechnet man den einfachen Moving Average des typischen Preises (die SMA), und schließlich wird der endgültige CCI-Wert durch den Abzug des SMA durch den typischen Preis und die Multiplikation mit 0,015 durch die durchschnittliche Abweichung erhalten. Wenn der CCI-Wert unter 90 liegt, zeigt dies an, dass der Markt möglicherweise überverkauft ist.
Die Strategie nutzt die CCI-Indikatoren, um Marktübersätze zu erfassen. Sie ist mit Stop-Loss- und Profit-Closing-Mechanismen ausgestattet und bietet ein vollständiges Handelssystem. Die Strategie hat eine klare Logik, ist einfach zu implementieren und verfügt über eine gute Risikokontrolle.
/*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)