
この戦略は,CCI指標をベースに柔軟なトレンド追跡の自動取引システムを設計した.これは,CCI指標の0軸の上で穿越したり下穿越したりして取引信号を発信することができる.また,カスタマイズされた上下チャネル帯とチャネル帯の交差で信号を発信することもできる.戦略は,固定ストップ・ロス,ストップ・ストップの比率を設定することができ,同時に,時間帯取引と毎日の固定時間帯取引などの複数の機能を持つ.
CCI指標の0軸交差を利用して市場動向を判断する.CCI上の0軸は看板信号で,CCI下の0軸は看板信号である.
カスタムCCI上下通道帯を設定することで,CCI上上通道帯を看板信号として穿い,CCI下下通道帯を穿い,看板信号となります.通道帯の交差は止損信号となります.
特定の時間帯での取引のみを設定し,未取引時の平仓を設定できます. 毎日固定時間帯での取引を設定できます.
固定ストップ・ストップの比率を設定できます.
カスタマイズ可能な取引の開設に関するAlertメッセージ。
戦略は完全にカスタマイズ可能で,CCIパラメータ,通路帯パラメータ,停止停止パラメータなどの最適化戦略を調整できます.
CCIは価格変化に敏感で,市場の転換点を素早く捉えることができる.
カスタム通路帯は,異なる市場に応じてパラメータを調整することができ,通路帯の交差停止は,リスクを効果的に制御します.
複数の取引時間設定をサポートし,異なる時間帯に応じて戦略パラメータを調整し,異なる時間帯の特性を利用して余分な収益を得ることができます.
固定ストップ・ストップ・ストップの設定をサポートし,勝負比率を事前に設定し,個々の取引のリスクを効果的に制御します.
完全にカスタマイズ可能なパラメータにより,異なる品種や市場状況に合わせて戦略を最適化して,よりよい結果を得ることができます.
CCI指標は価格変化に敏感であり,部分的な偽信号を生成する可能性があるため,より長い周期の指標と組み合わせて検証すべきである.
固定ストップ・ストップの比率は,市場の変化に合わせて調整できないので,適正に保持して設定する比率はよい.
固定取引時間は,市場のショートラインの調整の機会を逃す可能性があり,取引価値のある時間帯を適切に選択する必要があります.
パラメータを頻繁に最適化する必要があり,不適切な最適化は過剰取引や取引機会の逃れにつながる可能性があります.
業界情勢やマクロ環境などの様々な要因と組み合わせる必要があるため,パラメータ最適化だけではリスクを完全に回避することはできません.
CCIは,長短周期指標と組み合わせて検証し,CCIが偽信号を生じさせないようにする.
ATRなどの指標を使って動的ストップダストを設定する.
異なる時間帯のパラメータの効果をテストし,取引が有効な時期を選択します.
CCIパラメータ,通路帯パラメータを最適化し,市場の変化に適応する.
トレンド,変動,取引量などの複数の要因を考慮して総合的な判断を行う.
取引品種の特徴に応じて適切な取引期間を選択してください.
機械学習アルゴリズムを導入し,戦略の自動最適化を検討する.
この戦略は,全体的に非常に柔軟でカスタマイズ可能なトレンド追跡取引システムである. 戦略は,CCIの判断トレンド,カスタム通路帯のリスク制御,固定ストップ・ロスの設定,取引時間の選択などの利点があります. 同時に,CCIが偽シグナルを生成しやすい,固定ストップ・ロスの割合が動的に調整できないなどの問題にも注意する必要があります.
/*backtest
start: 2023-10-01 00:00:00
end: 2023-10-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © REV0LUTI0N
//@version=4
strategy(title="CCI Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)
//CCI Code
length = input(20, minval=1, title="CCI Length")
src = input(close, title="Source")
ma = sma(src, length)
cci = (src - ma) / (0.015 * dev(src, length))
// Strategy Backtesting
startDate = input(timestamp("2099-10-01T00:00:00"), type = input.time, title='Backtesting Start Date')
finishDate = input(timestamp("9999-12-31T00:00:00"), type = input.time, title='Backtesting End Date')
time_cond = true
//Time Restriction Settings
startendtime = input("", title='Time Frame To Enter Trades')
enableclose = input(false, title='Enable Close Trade At End Of Time Frame')
timetobuy = true
timetoclose = true
//Strategy Settings
//Strategy Settings - Enable Check Boxes
enableentry = input(true, title="Enter First Trade ASAP")
enableconfirmation = input(false, title="Wait For Cross To Enter First Trade")
enablezero =input(true, title="Use CCI Simple Cross Line For Entries & Exits")
enablebands = input(false, title="Use Upper & Lower Bands For Entries & Exits")
//Strategy Settings - Band Sources
ccisource = input(0, title="CCI Simple Cross")
upperbandsource =input(100, title="CCI Enter Long Band")
upperbandexitsource =input(100, title="CCI Exit Long Band")
lowerbandsource =input(-100, title="CCI Enter Short Band")
lowerbandexitsource =input(-100, title="CCI Exit Short Band")
//Strategy Settings - Crosses
simplecrossup = crossover(cci, ccisource)
simplecrossdown = crossunder(cci, ccisource)
uppercrossup = crossover(cci, upperbandsource)
lowercrossdown = crossunder(cci, lowerbandsource)
uppercrossdown = crossunder(cci, upperbandexitsource)
lowercrossup = crossover(cci, lowerbandexitsource)
upperstop = crossunder(cci, upperbandsource)
lowerstop = crossover(cci, lowerbandsource)
// Stop Loss & Take Profit % Based
enablesl = input(false, title='Enable Stop Loss')
enabletp = input(false, title='Enable Take Profit')
stopTick = input(5.0, title='Stop Loss %', type=input.float, step=0.1) / 100
takeTick = input(10.0, title='Take Profit %', type=input.float, step=0.1) / 100
longStop = strategy.position_avg_price * (1 - stopTick)
shortStop = strategy.position_avg_price * (1 + stopTick)
shortTake = strategy.position_avg_price * (1 - takeTick)
longTake = strategy.position_avg_price * (1 + takeTick)
plot(strategy.position_size > 0 and enablesl ? longStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Long Fixed SL")
plot(strategy.position_size < 0 and enablesl ? shortStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Short Fixed SL")
plot(strategy.position_size > 0 and enabletp ? longTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Long Take Profit")
plot(strategy.position_size < 0 and enabletp ? shortTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Short Take Profit")
// Alert messages
message_enterlong = input("", title="Long Entry message")
message_entershort = input("", title="Short Entry message")
message_closelong = input("", title="Close Long message")
message_closeshort = input("", title="Close Short message")
//Strategy Execution
//Strategy Execution - Simple Line Cross
if (cci > ccisource and enablezero and enableentry and time_cond and timetobuy)
strategy.entry("Long", strategy.long, alert_message = message_enterlong)
if (cci < ccisource and enablezero and enableentry and time_cond and timetobuy)
strategy.entry("Short", strategy.short, alert_message = message_entershort)
if (simplecrossup and enablezero and enableconfirmation and time_cond and timetobuy)
strategy.entry("Long", strategy.long, alert_message = message_enterlong)
if (simplecrossdown and enablezero and enableconfirmation and time_cond and timetobuy)
strategy.entry("Short", strategy.short, alert_message = message_entershort)
//Strategy Execution - Upper and Lower Band Entry
if (uppercrossup and enablebands and time_cond and timetobuy)
strategy.entry("Long", strategy.long, alert_message = message_enterlong)
if (lowercrossdown and enablebands and time_cond and timetobuy)
strategy.entry("Short", strategy.short, alert_message = message_entershort)
//Strategy Execution - Upper and Lower Band Exit
if strategy.position_size > 0 and uppercrossdown and enablebands and time_cond and timetobuy
strategy.close_all(alert_message = message_closelong)
if strategy.position_size < 0 and lowercrossup and enablebands and time_cond and timetobuy
strategy.close_all(alert_message = message_closeshort)
//Strategy Execution - Upper and Lower Band Stops
if strategy.position_size > 0 and upperstop and enablebands and time_cond and timetobuy
strategy.close_all(alert_message = message_closelong)
if strategy.position_size < 0 and lowerstop and enablebands and time_cond and timetobuy
strategy.close_all(alert_message = message_closeshort)
//Strategy Execution - Close Trade At End Of Time Frame
if strategy.position_size > 0 and timetoclose and enableclose and time_cond
strategy.close_all(alert_message = message_closelong)
if strategy.position_size < 0 and timetoclose and enableclose and time_cond
strategy.close_all(alert_message = message_closeshort)
//Strategy Execution - Stop Loss and Take Profit
if strategy.position_size > 0 and enablesl and time_cond
strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)
if strategy.position_size < 0 and enablesl and time_cond
strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)
if strategy.position_size > 0 and enabletp and time_cond
strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)
if strategy.position_size < 0 and enabletp and time_cond
strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)