
この戦略は,商品通路指標 ((CCI)) に基づく動的取引システムで,価格が平均値から偏っている程度を監視することによって,市場の超売り領域の取引機会を捉えるためのものです.戦略は,12サイクルを逆行期として採用し,CCI指標が90値を下回ったときに多額の入場を行います.
戦略の核心は,価格と平均値との偏差を測定するためにCCI指標を使用することです.CCIの計算プロセスは,まず,典型的な価格 ((最高価格,最低価格,および終止価格の算術平均) を計算し,次に典型的な価格の単純な移動平均 ((SMA) を計算し,最後に,典型的な価格からSMAを減算して,平均偏差で0.015で割ると,最終的なCCI値が得られます.CCI値が90を下回ると,市場が超売り状態にある可能性があることを示し,市場が多額の取引をするとき;価格が前期の高値を突破すると,上昇傾向が確立し,平仓利得をするとき.戦略はまた,止損と利得の終了パラメータの設定オプションを提供し,トレーダーのリスク好みに応じて柔軟に調整することができます.
この戦略は,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)