Ini adalah strategi perdagangan berdasarkan pelbagai purata bergerak dan kejayaan momentum. Strategi ini menggabungkan penunjuk teknikal seperti SMMA (Smoothed Moving Average) dan ZLEMA (Zero-Lag Exponential Moving Average) untuk mengenal pasti peluang perdagangan dengan menangkap isyarat silang antara harga dan purata bergerak. Strategi ini menggunakan mekanisme adaptif yang menyesuaikan kepekaan isyarat berdasarkan turun naik pasaran untuk meningkatkan ketepatan perdagangan.
Strategi ini menggunakan empat purata bergerak utama: src (SMMA berdasarkan HLC3), hi (SMMA berdasarkan tinggi), lo (SMMA berdasarkan rendah), dan mi (ZLEMA berdasarkan src). Isyarat perdagangan terutamanya berdasarkan hubungan silang dan kedudukan relatif antara purata bergerak ini. Gabungan pelbagai keadaan isyarat memastikan kebolehpercayaan isyarat perdagangan. Isyarat beli termasuk empat kombinasi keadaan yang berbeza, dan isyarat jual juga termasuk empat kombinasi keadaan yang berbeza. Isyarat keluar berdasarkan silang harga dengan purata mi dan kedudukan relatif antara purata bergerak.
Strategi ini membina sistem perdagangan yang agak lengkap melalui gabungan pelbagai purata bergerak dan penunjuk momentum. Ciri-ciri adaptif strategi dan pelbagai mekanisme pengesahan meningkatkan kebolehpercayaan perdagangan. Melalui pengoptimuman dan penyempurnaan, strategi ini mempunyai potensi untuk mengekalkan prestasi yang stabil dalam persekitaran pasaran yang berbeza.
/*backtest start: 2024-01-10 00:00:00 end: 2025-01-08 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=6 //study("Limit order strategy", overlay=true) strategy('Limit order strategy', overlay = true) lengthMA = input(1) lengthmi = input(14) lengthhigh = input(14) lengthlow = input(14) calc_smma(src, len) => smma = 0.0 smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len smma calc_zlema(src, length) => ema1 = ta.ema(src, length) ema2 = ta.ema(ema1, length) d = ema1 - ema2 ema1 + d src = calc_smma(hlc3, lengthMA) hi = calc_smma(high, lengthhigh) lo = calc_smma(low, lengthlow) mi = calc_zlema(src, lengthmi) plot(src, color = color.new(#FF1493, 0), linewidth = 2, title = 'src') plot(hi, color = color.new(#7CFC00, 0), linewidth = 2, title = 'hi') plot(lo, color = color.new(#FF0000, 0), linewidth = 2, title = 'lo') plot(mi, color = color.new(#00FFFF, 0), linewidth = 2, title = 'mi') //strategy.order("buy", true, 1, stop = na, when = openbuy) // buy by market if current open great then previous high //strategy.order("sell", false, 1, stop = na, when = opensell) // sell by market if current open less then previous low //if src >= mi and src[1] <= mi[1] and src[1] <= lo[1] // strategy.entry("buy 1", strategy.long, qty = 15) sigorderbuy1 = src > mi and src[1] < mi[1] and src < lo and mi < lo sigorderbuy2 = src > lo and src[1] < lo[1] and mi < lo sigorderbuy3 = src > hi and src[1] < hi[1] and mi < hi sigorderbuy4 = src > mi and src[1] < mi[1] and src > hi and mi > hi //sigorderbuy5 = mi > hi and src > hi and src > mi and src[1] < mi[1] //sigorderbuy6 = mi < hi and src > hi and src[1] < hi[1] sigclosebuy = src < mi and src[1] > mi[1] or mi < lo and src < lo and src[1] > lo[1] sigordersell1 = src < mi and src[1] > mi[1] and src > hi and mi > hi sigordersell2 = src < hi and src[1] > hi[1] and mi > hi sigordersell3 = src < lo and src[1] > lo[1] and mi > lo sigordersell4 = src < mi and src[1] > mi[1] and src < lo and mi < lo //sigordersell5 = mi < lo and src < lo and src < mi and src[1] > mi[1] //sigordersell6 = mi > lo and src < lo and src[1] > lo[1] sigclosesell = src > mi and src[1] < mi[1] or mi > hi and src > hi and src[1] < hi[1] plot(sigorderbuy1 ? 1 : 0, 'sigorderbuy1') plot(sigorderbuy2 ? 1 : 0, 'sigorderbuy2') plot(sigorderbuy3 ? 1 : 0, 'sigorderbuy3') plot(sigorderbuy4 ? 1 : 0, 'sigorderbuy4') //plot(sigorderbuy5 ? 1 : 0,"sigorderbuy5") //plot(sigorderbuy6 ? 1 : 0,"sigorderbuy6") plot(sigordersell1 ? 1 : 0, 'sigordersell1') plot(sigordersell2 ? 1 : 0, 'sigordersell2') plot(sigordersell3 ? 1 : 0, 'sigordersell3') plot(sigordersell4 ? 1 : 0, 'sigordersell4') //plot(sigordersell5 ? 1 : 0,"sigordersell5") //plot(sigordersell6 ? 1 : 0,"sigordersell6") plot(sigclosebuy ? 1 : 0, 'sigclosebuy') plot(sigclosesell ? 1 : 0, 'sigclosesell') openbuy = sigorderbuy1 or sigorderbuy2 or sigorderbuy3 or sigorderbuy4 // or sigorderbuy5 or sigorderbuy6 opensell = sigordersell1 or sigordersell2 or sigordersell3 or sigordersell4 //or sigordersell5 or sigordersell6 openclosebuy = sigclosebuy openclosesell = sigclosesell alertcondition(condition = openbuy, title = 'sigorderbuy all', message = '{"accountmt":"70415621,666734890","time":"15","msg":"Buy {{ticker}} sig_b1={{plot("sigorderbuy1")}} sig_b2={{plot("sigorderbuy2")}} sig_b3={{plot("sigorderbuy3")}} sig_b4={{plot("sigorderbuy4")}}"}') alertcondition(condition = opensell, title = 'sigordersell all', message = '{"accountmt":"70415621,666734890","time":"15","msg":"Sell {{ticker}} sig_s1={{plot("sigordersell1")}} sig_ss={{plot("sigordersell2")}} sig_s3={{plot("sigordersell3")}} sig_s4={{plot("sigordersell4")}} sig_s5={{plot("sigordersell5")}} sig_61={{plot("sigordersell6")}}"}') alertcondition(condition = sigclosebuy, title = 'Close buy', message = '{"accountmt":"70415621,666734890","time":"15","msg":"Close {{ticker}} T=short"}') alertcondition(condition = sigclosesell, title = 'Close sell', message = '{"accountmt":"70415621,666734890","time":"15","msg":"Close {{ticker}} T=long"}') if sigorderbuy1 strategy.order('Buy 1', strategy.long, 1) if sigorderbuy2 strategy.order('Buy 2', strategy.long, 1) if sigorderbuy3 strategy.order('Buy 3', strategy.long, 1) if sigorderbuy4 strategy.order('Buy 4', strategy.long, 1) if sigordersell1 strategy.order('sell 1', strategy.short, 1) if sigordersell2 strategy.order('sell 2', strategy.short, 1) if sigordersell3 strategy.order('sell 3', strategy.short, 1) if sigordersell4 strategy.order('sell 4', strategy.short, 1) //strategy.order("sell 5", false, 1, when = sigordersell5) //strategy.order("sell 6", false, 1, when = sigordersell6)