Ini adalah strategi trading yang didasarkan pada beberapa moving average dan momentum breakthrough. Strategi ini menggabungkan indikator teknis seperti SMMA (Smoothed Moving Average) dan ZLEMA (Zero-Lag Exponential Moving Average) untuk mengidentifikasi peluang trading dengan menangkap sinyal crossover antara harga dan moving average. Strategi ini menggunakan mekanisme adaptif yang menyesuaikan sensitivitas sinyal berdasarkan volatilitas pasar untuk meningkatkan akurasi trading.
Strategi ini menggunakan empat rata-rata bergerak utama: src (SMMA berdasarkan HLC3), hi (SMMA berdasarkan tinggi), lo (SMMA berdasarkan rendah), dan mi (ZLEMA berdasarkan src). Sinyal perdagangan terutama didasarkan pada hubungan silang dan posisi relatif antara rata-rata bergerak ini. Kombinasi dari beberapa kondisi sinyal memastikan keandalan sinyal perdagangan. Sinyal beli mencakup empat kombinasi kondisi yang berbeda, dan sinyal jual juga mencakup empat kombinasi kondisi yang berbeda. Sinyal keluar didasarkan pada penyeberangan harga dengan rata-rata mi dan posisi relatif antara rata-rata bergerak.
Strategi ini membangun sistem perdagangan yang relatif lengkap melalui kombinasi beberapa moving average dan indikator momentum. Fitur adaptif strategi dan beberapa mekanisme konfirmasi meningkatkan keandalan perdagangan. Melalui optimasi dan penyempurnaan, strategi ini memiliki potensi untuk mempertahankan kinerja yang stabil di lingkungan pasar yang berbeda. Pedagang disarankan untuk melakukan backtesting menyeluruh dan optimasi parameter sebelum perdagangan langsung.
/*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)