
이 전략은 상품 통로 지표 ((CCI) 를 기반으로 한 동적 거래 시스템으로, 가격의 평균에서 벗어난 정도를 모니터링하여 시장의 과매매 지역에서의 거래 기회를 포착합니다. 전략은 12 개의 주기를 회귀 기간으로 사용하며, CCI 지표가 90 하락을 넘어가는 경우 더 많이 입게됩니다.
전략의 핵심은 가격과 평균 사이의 오차를 측정하기 위해 CCI 지표를 사용하는 것입니다. CCI의 계산 과정은 다음과 같습니다: 먼저 전형적인 가격을 계산합니다 (최고 가격, 최저 가격 및 종료 가격의 수학적 평균), 다음으로 전형적인 가격의 간단한 이동 평균을 계산합니다 (SMA), 마지막으로 전형적인 가격을 빼고 평균 오차로 0.015을 곱하면 최종 CCI 값을 얻습니다.
이 전략은 CCI 지표를 통해 시장 과매매 기회를 포착하고, 스톱로스 및 수익 결제 메커니즘을 지원하며, 완전한 거래 시스템을 구현한다. 전략 논리는 명확하고, 실행하기 쉽고, 좋은 위험 제어 능력을 갖추고 있다. 신호 필터링, 동적 하락과 같은 최적화 수단을 도입함으로써 전략의 안정성과 수익성을 향상시킬 여지가 있다. 거래자는 실제 사용 전에 충분한 피드백을 수행하고, 특정 시장 특성에 따라 매개 변수 설정을 조정하는 것이 좋습니다.
/*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)