Strategi Momentum Pulangan Min


Tarikh penciptaan: 2023-11-15 17:40:59 Akhirnya diubah suai: 2023-11-15 17:40:59
Salin: 0 Bilangan klik: 833
1
fokus pada
1617
Pengikut

Strategi Momentum Pulangan Min

Gambaran keseluruhan

Strategi dinamika pulangan rata-rata adalah strategi perdagangan trend yang mengesan purata harga jangka pendek. Ia menggabungkan indikator pulangan rata-rata dan indikator dinamika untuk menilai trend pasaran jangka menengah.

Prinsip Strategi

Strategi ini pertama-tama mengira garis pulangan rata-rata dan perbezaan piawai harga. Kemudian menggabungkan parameter Upper Threshold dan Lower Threshold yang ditetapkan dengan baik untuk mengira apakah harga melebihi satu jarak perbezaan piawai garis pulangan rata-rata. Jika melebihi, isyarat perdagangan dihasilkan.

Untuk isyarat berbilang arah, diperlukan harga di bawah garis pengembalian nilai rata-rata satu perbezaan piawai, harga tutup di bawah garis purata SMA untuk kitaran LENGTH, dan lebih tinggi daripada garis purata SMA TREND, memenuhi ketiga-tiga syarat untuk melakukan kedudukan terbuka dalam pelbagai arah. Syarat kedudukan terbuka adalah garis purata SMA untuk kitaran LENGTH.

Untuk isyarat kosong, diperlukan harga yang lebih tinggi daripada garis pulangan nilai rata-rata satu perbezaan standard, harga tutup lebih tinggi daripada purata SMA kitaran LENGTH, dan lebih rendah daripada purata SMA TREND, memenuhi ketiga-tiga syarat ini untuk membuka posisi dalam arah yang kosong. Syarat kedudukan kosong adalah purata SMA kitaran LENGTH di bawah harga.

Strategi ini digabungkan dengan Peratusan Target Keuntungan dan Peratusan Hentikan Kerugian untuk mencapai pengurusan hentikan kerugian.

Cara keluar boleh memilih untuk menembusi purata bergerak atau regresi linear.

Perdagangan dua hala berbilang ruang, penapisan trend, dan penghentian stop-loss membolehkan penilaian dan pengesanan trend jangka menengah pasaran.

Kelebihan Strategik

  1. Indeks Regression Mean Value dapat menentukan dengan berkesan sama ada harga menyimpang dari pusat nilai

  2. Indeks momentum SMA menapis bunyi pasaran jangka pendek

  3. Perdagangan dua hala pelbagai ruang untuk menangkap peluang trend secara menyeluruh

  4. Mekanisme Stop Loss boleh mengawal risiko dengan berkesan

  5. Pilihan untuk keluar yang fleksibel untuk menyesuaikan diri dengan pasaran

  6. Strategi perdagangan trend yang lengkap untuk lebih memahami trend pertengahan

Risiko Strategik

  1. Indeks Regression Mean Sensitive terhadap tetapan parameter, tetapan yang tidak betul boleh menyebabkan isyarat palsu

  2. Keadaan yang boleh menyebabkan kemerosotan yang terlalu kerap dalam keadaan gegaran besar

  3. Frekuensi dagangan mungkin terlalu tinggi semasa tren goyah, meningkatkan kos dagangan dan risiko slippage

  4. Pengendalian titik geser mungkin tidak sesuai apabila terdapat kecairan dalam jenis dagangan

  5. Perdagangan dua hala MLM berisiko tinggi dan memerlukan pengurusan dana yang berhati-hati

Risiko ini boleh dikawal dengan cara seperti pengoptimuman parameter, penyesuaian dengan cara menghentikan kerugian, dan pengurusan wang.

Arah pengoptimuman strategi

  1. Pengaturan parameter yang dioptimumkan untuk pulangan nilai purata dan dinamika untuk menjadikannya lebih sesuai dengan ciri-ciri pelbagai jenis

  2. Meningkatkan indikator penilaian trend, meningkatkan keupayaan untuk mengenal pasti trend

  3. Mengoptimumkan strategi henti kerugian untuk lebih beradaptasi dengan turun naik pasaran yang besar

  4. Menambah modul pengurusan kedudukan, menyesuaikan saiz kedudukan mengikut keadaan pasaran

  5. Tambah modul kawalan angin seperti kawalan penarikan balik maksimum, kawalan kurva nilai bersih dan sebagainya

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

ringkaskan

Secara keseluruhannya, strategi dinamika nilai pulangan rata-rata berjaya menangkap trend pulangan nilai jangka menengah melalui reka bentuk penunjuk yang mudah dan berkesan. Strategi ini mempunyai daya serap yang kuat dan keserasian, tetapi ada juga risiko tertentu.

Kod sumber strategi
/*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))