Strategi Momentum Pembalikan Purata

Penulis:ChaoZhang, Tarikh: 2023-11-15 17:40:59
Tag:

img

Ringkasan

Strategi momentum pembalikan purata adalah strategi perdagangan trend yang mengesan purata harga jangka pendek. Ia menggabungkan penunjuk pembalikan purata dan penunjuk momentum untuk menilai trend pasaran jangka sederhana.

Logika Strategi

Strategi ini mula-mula mengira garis pembalikan purata dan penyimpangan standard harga. Kemudian, digabungkan dengan nilai ambang yang ditetapkan oleh parameter Ambang Atas dan Ambang Bawah, ia mengira sama ada harga melebihi julat satu penyimpangan standard dari garis pembalikan purata. Jika ya, isyarat perdagangan dihasilkan.

Untuk isyarat panjang, harga perlu berada di bawah garis pembalikan purata dengan satu penyimpangan standard, harga Penutupan di bawah SMA tempoh LENGTH, dan di atas SMA TREND, jika ketiga-tiga syarat ini dipenuhi, kedudukan panjang akan dibuka.

Untuk isyarat pendek, harga perlu berada di atas garis pembalikan purata dengan satu penyimpangan standard, harga Penutupan di atas SMA tempoh LENGTH, dan di bawah SMA TREND, jika ketiga-tiga syarat ini dipenuhi, kedudukan pendek akan dibuka.

Strategi ini juga menggabungkan Sasaran Keuntungan Peratusan dan Peratusan Stop Loss untuk mengambil keuntungan dan pengurusan stop loss.

Kaedah keluar boleh memilih antara crossover purata bergerak atau crossover regresi linear.

Melalui gabungan perdagangan dua arah, penapisan trend, mengambil keuntungan dan menghentikan kerugian, dll., Ia merealisasikan penilaian dan penjejakan trend pasaran jangka menengah.

Kelebihan

  1. Penunjuk pembalikan purata dapat menilai penyimpangan harga dari pusat nilai dengan berkesan.

  2. Indikator momentum SMA boleh menapis bunyi pasaran jangka pendek.

  3. Perdagangan dua arah dapat sepenuhnya menangkap peluang trend dalam semua arah.

  4. Mekanisme mengambil keuntungan dan menghentikan kerugian dapat mengawal risiko dengan berkesan.

  5. Kaedah keluar yang boleh dipilih boleh fleksibel untuk menyesuaikan diri dengan keadaan pasaran.

  6. Strategi perdagangan trend yang lengkap yang lebih menangkap trend jangka sederhana.

Risiko

  1. Penunjuk pembalikan purata sensitif kepada tetapan parameter, tetapan ambang yang tidak betul boleh menyebabkan isyarat palsu.

  2. Dalam keadaan pasaran yang tidak menentu, stop loss boleh diaktifkan terlalu kerap.

  3. Dalam trend sampingan, kekerapan dagangan mungkin terlalu tinggi, meningkatkan kos dagangan dan risiko tergelincir.

  4. Apabila instrumen dagangan mempunyai kecairan yang tidak mencukupi, kawalan slippage mungkin kurang optimum.

  5. Perdagangan dua arah mempunyai risiko yang lebih tinggi, pengurusan wang yang berhati-hati diperlukan.

Risiko ini boleh dikawal melalui pengoptimuman parameter, penyesuaian stop loss, pengurusan wang dll.

Arahan pengoptimuman

  1. Mengoptimumkan tetapan parameter pengembalian purata dan penunjuk momentum untuk lebih sesuai dengan instrumen perdagangan yang berbeza.

  2. Tambah penunjuk pengenalan trend untuk meningkatkan keupayaan pengenalan trend.

  3. Mengoptimumkan strategi stop loss untuk menyesuaikan diri dengan lebih baik dengan turun naik pasaran yang ketara.

  4. Tambah modul saiz kedudukan untuk menyesuaikan saiz kedudukan berdasarkan keadaan pasaran.

  5. Tambah lebih banyak modul pengurusan risiko, seperti kawalan pengambilan maksimum, kawalan kurva ekuiti dan lain-lain.

  6. Pertimbangkan menggabungkan kaedah pembelajaran mesin untuk mengoptimumkan parameter strategi secara automatik.

Ringkasan

Ringkasnya, strategi momentum pembalikan purata menangkap trend pembalikan purata jangka menengah melalui reka bentuk penunjuk yang mudah dan berkesan. Strategi ini mempunyai daya adaptasi dan serba boleh yang kuat, tetapi juga mempunyai beberapa risiko. Dengan pengoptimuman berterusan dan menggabungkan dengan strategi lain, prestasi yang lebih baik dapat dicapai. Secara keseluruhan strategi ini agak lengkap, dan merupakan kaedah perdagangan trend yang patut dipertimbangkan.


/*backtest
start: 2023-10-15 00:00:00
end: 2023-11-14 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: Mean Reversion Strategy", overlay=true)

LongShort       = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
Lookback        = input(title="Length", type=input.integer, defval=10, minval=0)
LThr1           = input(title="Upper threshold", type=input.float, defval=1, minval=0)
LThr            = input(title="Lower threshold", type=input.float, defval=-1, maxval=0)
src             = input(title="Source", type=input.source, defval=close)
LongShort2      = input(title="Linear Regression Exit or Moving Average Exit?", type=input.string, defval="MA", options=["LR", "MA"])
SMAlenL         = input(title="MA/LR Exit Length", type = input.integer ,defval=10)
SMALen2         = input(title="Trend SMA Length", type = input.integer ,defval=200)
AboveBelow      = input(title="Above or Below Trend SMA?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
PTbutton        = input(title="Profit Target On/Off", type=input.bool, defval=true)
ProfitTarget    = input(title="Profit Target %", type=input.float, defval=1, step=0.1, minval=0)
SLbutton        = input(title="Stop Loss On/Off", type=input.bool, defval=true)
StopLoss        = input(title="Stop Loss %", type=input.float, defval=-1, step=0.1, maxval=0)

x               = (src-linreg(src,Lookback,0))/(stdev(src,Lookback))

plot(linreg(src,Lookback,0))

//PROFIT TARGET & STOPLOSS

if PTbutton == true and SLbutton == true
    strategy.exit("EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick), loss=((close*(StopLoss*-0.01))/syminfo.mintick))
else
    if PTbutton == true and SLbutton == false
        strategy.exit("PT EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick))
    else
        if PTbutton == false and SLbutton == true
            strategy.exit("SL EXIT", loss=((close*(StopLoss*-0.01))/syminfo.mintick))
        else    
            strategy.cancel("PT EXIT")


////////////////////////
//MOVING AVERAGE EXIT//
//////////////////////

if LongShort=="Long Only" and AboveBelow=="Above" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close>sma(close,SMALen2))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort=="Long Only" and AboveBelow=="Below" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close<sma(close,SMALen2))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort=="Long Only" and AboveBelow=="Don't Include" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
///////    
    
if LongShort=="Short Only" and AboveBelow=="Above" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close>sma(close,SMALen2))
    strategy.close("SHORT", when = close<sma(close,SMAlenL))

if LongShort=="Short Only" and AboveBelow=="Below" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL)   and close<sma(close,SMALen2))
    strategy.close("SHORT", when = close<sma(close,SMAlenL))

if LongShort=="Short Only" and AboveBelow=="Don't Include" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1  and close>sma(close,SMAlenL)  )
    strategy.close("SHORT", when = close<sma(close,SMAlenL))
    
//////

if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close>sma(close,SMALen2))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close<sma(close,SMALen2))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
///////    
    
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close>sma(close,SMALen2))
    strategy.close("SHORT", when = close<sma(close,SMAlenL))

if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close<sma(close,SMALen2))
    strategy.close("SHORT", when = close<sma(close,SMAlenL))

if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) )
    strategy.close("SHORT", when = close<sma(close,SMAlenL))
    
/////////////////
//LIN REG EXIT//
///////////////

if LongShort=="Long Only" and AboveBelow=="Above" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))

if LongShort=="Long Only" and AboveBelow=="Below" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))

if LongShort=="Long Only" and AboveBelow=="Don't Include" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) )
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
    
///////    
    
if LongShort=="Short Only" and AboveBelow=="Above" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))

if LongShort=="Short Only" and AboveBelow=="Below" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0)   and close<sma(close,SMALen2))
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))

if LongShort=="Short Only" and AboveBelow=="Don't Include" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1  and close>linreg(close,SMAlenL,0)  )
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
    
//////

if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))

if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))

if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) )
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
    
///////    
    
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))

if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))

if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) )
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))






Lebih lanjut