
Strategi perdagangan yang kuat dengan dua rata-rata bergerak menggabungkan kekuatan dua kali ganda indeks yang agak kuat (RSI) dan indikator kadar perubahan (ROC) untuk mengenal pasti arah trend garis tengah yang panjang. Strategi ini menetapkan syarat penapisan dan syarat berhenti pada masa yang sama, mewujudkan Entry berdasarkan pengesahan arah trend, yang dapat mengurangkan risiko yang ditimbulkan oleh pelanggaran palsu.
Strategi ini berdasarkan gabungan RSI dan ROC untuk menentukan masa masuk. Apabila harga mendekati kawasan oversold relatif, ia dianggap sebagai titik perubahan struktur dan membentuk isyarat pembalikan. Apabila harga bergelombang di kawasan oversold relatif, ia menunjukkan bahawa trend semasa akan berlangsung untuk beberapa waktu.
Selain itu, strategi ini menambah dua syarat penapisan SMA dan garis hentian jangka pendek yang dinilai oleh trend garis panjang, yang membolehkan strategi hanya disahkan ke arah trend garis panjang, tanpa risiko hentian dalam jangka pendek. Cara penempatan ini dapat mengurangkan peluang untuk terkurung dalam keadaan goyah, risiko dapat dikawal oleh pedagang.
Tetapan input yang fleksibel dalam strategi ini juga membolehkan peniaga bebas memilih untuk menggunakan hanya RSI atau ROC dari salah satu indikator sebagai asas masuk, atau menggunakan kombinasi keduanya, yang dapat dioptimumkan untuk pelbagai jenis dan jenis situasi, yang memperluaskan lagi kelayakan strategi.
Kelebihan terbesar strategi ini adalah penghakiman masuk yang digabungkan dengan trend dan isyarat pembalikan, mempertimbangkan faktor trend dan peluang struktural, berdasarkan perubahan struktur pasaran, untuk memastikan ketepatan masa masuk. Penggunaan gabungan RSI dan ROC juga menjadikan strategi ini lebih tahan terhadap gangguan acak di pasaran berbanding dengan satu indikator.
Kelebihan lain ialah penapis trend (SMA) dan penghentian jangka pendek yang terbina dalam strategi, yang dapat mengurangkan kebarangkalian penempatan dalam keadaan yang bergolak. Pengaturan kedua-dua garis pertahanan penghakiman trend dan penghentian jangka pendek menjadikan ini strategi yang stabil dan terkawal dengan risiko.
Akhirnya, strategi ini mempunyai pelbagai seting parameter yang boleh dioptimumkan oleh peniaga untuk pelbagai jenis dan jenis situasi, yang menjadikan strategi ini sangat luas. Strategi ini boleh disesuaikan dengan perubahan pasaran melalui parameter, sama ada dalam keadaan trend atau keadaan yang stabil.
Risiko terbesar dalam strategi ini adalah terdapat beberapa kelewatan dalam indikator isyarat pembalikan seperti RSI dan ROC. Apabila trend berubah, indikator ini sering mempunyai kelewatan untuk membuat parameter mencapai tahap ambang yang ditetapkan. Kelewatan ini menyebabkan strategi memasuki masa yang terlambat dan tidak dapat menangkap tahap permulaan trend.
Risiko lain yang berpotensi adalah bahawa dalam trend goyah, parameter RSI dan ROC mungkin terlalu sensitif, yang menyebabkan beberapa isyarat palsu. Isyarat palsu ini akan menyebabkan kerugian sebenar secara langsung jika berhenti jangka pendek dicetuskan.
Strategi ini boleh dioptimumkan dalam beberapa aspek:
Menambahkan lebih banyak penunjuk untuk kombinasi, seperti KDJ, MACD dan lain-lain, menggunakan lebih banyak dimensi untuk menilai struktur pasaran, meningkatkan ketepatan isyarat
Penambahan mekanisme penyesuaian penyesuaian kepada parameter RSI dan ROC yang membolehkan parameter penunjuk disesuaikan secara dinamik mengikut turun naik masa nyata
Mengoptimumkan logik kemasukan, menetapkan mekanisme pengesahan tertentu apabila indikator trend dan indikator pembalikan memenuhi syarat, mengelakkan isyarat palsu yang muncul dalam gegaran
Memperluas julat hentian atau menetapkan hentian bebas untuk memberi lebih banyak ruang untuk berbalik untuk mengurangkan keuntungan yang hilang yang disebabkan oleh hentian yang terlalu ketat
Strategi perdagangan yang stabil dengan dua rata-rata bergerak berjaya menggabungkan penilaian trend dan indikator pembalikan untuk menangkap peluang struktur berdasarkan pengesahan trend garis tengah dan panjang. Strategi ini juga mempunyai konfigurasi yang kuat, dan pedagang dapat mengoptimumkan parameter untuk jenis saham dan situasi individu.
/*backtest
start: 2024-01-05 00:00:00
end: 2024-02-04 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/
// © GlobalMarketSignals
//@version=4
strategy("GMS: RSI & ROC Strategy", overlay=true)
LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
RSIroc = input(title="RSI Only, ROC Only, Both?", type=input.string, defval="Both", options=["Both", "RSI Only", "ROC Only"])
RSILength = input(title="RSI Length", type = input.integer ,defval=14)
RSIUpper = input(title="RSI Upper Threshold", type = input.float ,defval=70)
RSILower = input(title="RSI Lower Threshold", type = input.float ,defval=30)
ROCLength = input(title="ROC Length", type = input.integer ,defval=14)
ROCUpper = input(title="ROC Upper Threshold", type = input.float ,defval=0.01)
ROCLower = input(title="ROC Lower Threshold", type = input.float ,defval=-0.01)
LongExit = input(title="Long Exit SMA Length", type = input.integer ,defval=5)
ShortExit = input(title="Short Exit SMA Length", type = input.integer ,defval=5)
AboveBelow = input(title="Trend SMA Filter?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
TrendLength = input(title="Trend SMA Length", type = input.integer ,defval=200)
//RSI ONLY
//Long Side
if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Below" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Don't Include" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "RSI Only"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
//RSI ONLY
//SHORT SIDE
if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Below" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Don't Include" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "RSI Only"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
///////-----------------/////////////
///////-----------------/////////////
///////-----------------/////////////
//ROC ONLY
//Long Side
if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Below" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Don't Include" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "ROC Only"
strategy.entry("LONG", true, when = rsi(close,ROCLength)<ROCLower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
//ROC ONLY
//SHORT SIDE
if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Below" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Don't Include" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "ROC Only"
strategy.entry("SHORT", false, when = roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
///////-----------------/////////////
///////-----------------/////////////
///////-----------------/////////////
//BOTH
//Long Side
if LongShort =="Long Only" and AboveBelow == "Above" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Below" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Long Only" and AboveBelow == "Don't Include" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close>sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit) and close<sma(close,TrendLength))
strategy.close("LONG", when = close>sma(close,LongExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "Both"
strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and roc(close,ROCLength)<ROCLower and close< sma(close,LongExit))
strategy.close("LONG", when = close>sma(close,LongExit))
//BOTH
//SHORT SIDE
if LongShort =="Short Only" and AboveBelow == "Above" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Below" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Short Only" and AboveBelow == "Don't Include" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Above" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close>sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Below" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit) and close<sma(close,TrendLength))
strategy.close("SHORT", when = close<sma(close,ShortExit))
if LongShort =="Both" and AboveBelow == "Don't Include" and RSIroc == "Both"
strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and roc(close,ROCLength)>ROCUpper and close> sma(close,ShortExit))
strategy.close("SHORT", when = close<sma(close,ShortExit))