RSI dan Strategi Penembusan Purata Bergerak

Penulis:ChaoZhang, Tarikh: 2024-01-24 14:31:01
Tag:

img

Ringkasan

RSI dan Strategi Pecahan Purata Bergerak adalah strategi kuantitatif yang menggunakan kedua-dua penunjuk RSI dan garis purata bergerak untuk menentukan peluang perdagangan.

Logika Strategi

  1. Mengira petunjuk RSI dan garis purata bergerak mudah berdasarkan parameter yang ditakrifkan oleh pengguna.

  2. Apabila RSI melintasi di atas garisan oversold (default 30), isyarat panjang dihasilkan jika harga berada di bawah LONG exit Moving Average.

  3. Apabila RSI melintasi di bawah garis overbought (default 70), isyarat pendek dihasilkan jika harga berada di atas purata bergerak keluar SHORT.

  4. Pengguna boleh memilih untuk menapis isyarat berdasarkan garis Moving Average trend. Isyarat hanya dihasilkan apabila harga di atas atau di bawah penapis Moving Average.

  5. Keluar ditentukan oleh garis LONG dan SHORT keluar Moving Average.

Analisis Kelebihan

  1. Reka bentuk penunjuk berganda meningkatkan ketepatan dengan menggabungkan dua faktor pasaran utama.

  2. Menggunakan ciri pembalikan rata-rata RSI dengan berkesan untuk mencari titik perubahan.

  3. Penapis tambahan dengan Moving Averages meningkatkan ketepatan logik untuk mengelakkan mengejar atas dan bawah.

  4. Parameter yang boleh disesuaikan membolehkan pengoptimuman merentasi produk dan jangka masa yang berbeza.

  5. Logik yang mudah menjadikannya mudah difahami dan diubah.

Analisis Risiko

  1. Whipsaws adalah biasa dengan RSI, Indikator ketumpatan boleh membantu.

  2. RSI cenderung gagal pada jangka masa yang lebih besar, parameter boleh diselaraskan atau penunjuk tambahan boleh membantu.

  3. Moving Averages mempunyai kesan kelewatan, panjang boleh diperpendek atau penunjuk seperti MACD boleh membantu.

  4. Lebih banyak penunjuk perlu diperkenalkan untuk mengesahkan isyarat kerana logik asas.

Arahan pengoptimuman

  1. Mengoptimumkan parameter RSI atau memperkenalkan penunjuk Ketumpatan untuk mengurangkan isyarat palsu.

  2. Menggabungkan penunjuk trend dan turun naik seperti DMI dan BOLL untuk mencari trend dan sokongan.

  3. Memperkenalkan MACD untuk menggantikan atau melengkapkan penilaian Purata Bergerak.

  4. Tambah lagi syarat logik pada isyarat masuk untuk mengelakkan breakouts yang tidak baik.

Kesimpulan

Strategi RSI dan Moving Average Breakout menggabungkan pengesanan overbought-oversold RSI dan penentuan trend Moving Averages untuk memanfaatkan peluang pembalikan purata secara teori. Strategi ini intuitif dan mudah digunakan untuk pemula, dan boleh dioptimumkan di pelbagai produk, menjadikannya strategi kuantitatif permulaan yang disyorkan. Lebih banyak penunjuk tambahan boleh diperkenalkan untuk mengesahkan isyarat dan meningkatkan keuntungan.


/*backtest
start: 2024-01-16 00:00:00
end: 2024-01-23 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Global Market Signals: RSI Strategy.
//@version=4
strategy("GMS: RSI Strategy", overlay=true)

LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
RSILength = input(title="RSI Length", type = input.integer ,defval=14)
RSIUpper = input(title="Upper Threshold", type = input.float ,defval=70)
RSILower = input(title="Lower Threshold", type = input.float ,defval=30)
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)


//Long Side

if LongShort =="Long Only" and AboveBelow == "Above"
    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"
    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"
    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"
    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"
    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"
    strategy.entry("LONG", true, when = rsi(close,RSILength)<RSILower and close< sma(close,LongExit))
    strategy.close("LONG", when = close>sma(close,LongExit))
    
    
//SHORT SIDE

if LongShort =="Short Only" and AboveBelow == "Above"
    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"
    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"
    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"
    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"
    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"
    strategy.entry("SHORT", false, when = rsi(close,RSILength)>RSIUpper and close> sma(close,ShortExit))
    strategy.close("SHORT", when = close<sma(close,ShortExit))
    
    
    
    
    
    
   





Lebih lanjut