
Strategi ini direka berdasarkan petunjuk CCI untuk sistem perdagangan automatik yang fleksibel untuk mengikuti trend. Ia boleh menghantar isyarat perdagangan melalui atau melalui pada sumbu 0 petunjuk CCI, atau melalui jalur saluran atas dan bawah yang disesuaikan. Strategi ini boleh menetapkan peratusan berhenti dan berhenti tetap, dan mempunyai pelbagai fungsi seperti perdagangan jangka masa dan perdagangan jangka masa tetap setiap hari.
Menggunakan penyambung 0 dari penunjuk CCI untuk menilai trend pasaran, CCI atas melalui 0 sebagai isyarat bullish, CCI bawah melalui 0 sebagai isyarat bearish.
Dengan menggunakan CCI atas dan bawah, apabila CCI atas memakai jalur atas sebagai isyarat bullish, CCI bawah memakai jalur bawah sebagai isyarat bearish. Persaingan jalur adalah isyarat stop loss.
Ia boleh ditetapkan hanya untuk perdagangan dalam tempoh masa tertentu, tidak diperdagangkan dalam tempoh masa kosong. Ia boleh ditetapkan untuk perdagangan dalam tempoh masa tetap setiap hari.
Anda boleh setkan peratusan stop loss dan stop loss tetap.
Mesej Alert yang boleh disesuaikan untuk membuka posisi kosong.
Strategi sepenuhnya disesuaikan dan fleksibel, anda boleh menyesuaikan parameter CCI, parameter jalur, parameter stop-loss dan strategi pengoptimuman.
CCI digunakan untuk menilai trend pasaran, CCI sensitif terhadap perubahan harga dan dapat menangkap titik perubahan pasaran dengan cepat.
Talian laluan tersuai boleh disesuaikan mengikut parameter pasaran yang berbeza, dan tali simpang laluan dapat mengawal risiko dengan berkesan.
Menyokong pelbagai tetapan masa perdagangan, parameter strategi boleh disesuaikan mengikut tempoh masa yang berbeza, memanfaatkan ciri-ciri tempoh masa yang berbeza untuk mendapatkan keuntungan tambahan.
Menyokong tetapan Stop Loss yang tetap, anda boleh menetapkan nisbah keuntungan dan kerugian, mengawal risiko perdagangan individu dengan berkesan.
Parameter yang boleh disesuaikan sepenuhnya, yang membolehkan anda mengoptimumkan strategi untuk varieti dan keadaan pasaran yang berbeza untuk mendapatkan hasil yang lebih baik.
Indeks CCI sensitif terhadap perubahan harga, dan mungkin menghasilkan beberapa isyarat palsu, yang harus disahkan dengan penunjuk kitaran yang lebih panjang.
Nisbah Stop Loss Stop tidak boleh disesuaikan dengan perubahan pasaran, nisbah harus disesuaikan dengan betul.
Waktu dagangan tetap mungkin terlepas peluang untuk menyesuaikan garis pendek pasaran, dan tempoh masa yang sesuai untuk nilai dagangan harus dipilih.
Parameter perlu sering dioptimumkan, jika pengoptimuman yang tidak betul boleh menyebabkan perdagangan berlebihan atau kehilangan peluang perdagangan.
Ia perlu digabungkan dengan pelbagai faktor seperti keadaan industri, persekitaran makro, dan lain-lain.
Untuk mengesahkan, ia perlu digabungkan dengan indikator jangka pendek dan panjang untuk mengelakkan isyarat palsu CCI.
Tetapan Stop Loss Dinamik menggunakan penunjuk seperti ATR.
Uji kesan parameter pada tempoh masa yang berbeza, pilih masa yang paling berkesan.
Mengoptimumkan parameter CCI, parameter jalur laluan, menyesuaikan diri dengan perubahan pasaran.
Mengambil kira pelbagai faktor seperti trend, turun naik, dan jumlah transaksi untuk membuat penilaian komprehensif.
Pilih tempoh perdagangan yang sesuai mengikut ciri-ciri jenis perdagangan.
Pertimbangkan untuk menggunakan algoritma pembelajaran mesin untuk mengoptimumkan strategi secara automatik.
Strategi ini secara keseluruhan adalah sistem perdagangan yang sangat fleksibel dan boleh disesuaikan. Strategi ini mempunyai banyak kelebihan seperti menggunakan CCI untuk menilai trend, mengawal risiko jalur tersuai, menetapkan stop loss tetap, memilih tempoh perdagangan, dan lain-lain. Anda juga perlu memperhatikan CCI yang mudah menghasilkan isyarat palsu, nisbah stop loss tetap tidak dapat disesuaikan secara dinamik.
/*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)