
이는 다중 이동 평균선과 모멘텀 돌파를 기반으로 한 거래 전략입니다. 이 전략은 SMMA(평활 이동 평균) 및 ZLEMA(제로 지연 지수 이동 평균)와 같은 여러 기술 지표를 결합하여 가격과 이동 평균 사이의 교차 신호를 포착하여 거래 기회를 식별합니다. 이 전략은 시장 변동에 따라 신호의 민감도를 조정하고 거래의 정확도를 향상시킬 수 있는 적응형 메커니즘을 채택합니다.
이 전략은 4개의 주요 이동 평균을 사용합니다. src(HLC3 기반 SMMA), hi(높음 기반 SMMA), lo(낮음 기반 SMMA), mi(src 기반 ZLEMA). 거래 신호는 주로 이러한 이동 평균선 간의 교차와 위치 관계를 기반으로 합니다. 여러 신호 조건의 조합은 거래 신호의 신뢰성을 보장합니다. 매수 신호에는 4가지 조건 조합이 포함되고, 매도 신호에도 4가지 조건 조합이 포함됩니다. 마감 신호는 가격과 이동평균선의 교차, 그리고 이동평균선 간의 위치 관계에 기초합니다.
이 전략은 여러 이동평균선과 모멘텀 지표를 결합하여 비교적 완전한 거래 시스템을 구축합니다. 전략의 적응적 특성과 다중 확인 메커니즘은 거래의 신뢰성을 향상시킵니다. 최적화와 개선을 통해 이 전략은 다양한 시장 환경에서도 안정적인 성과를 유지할 것으로 기대됩니다. 트레이더는 실시간 사용에 앞서 충분한 백테스팅과 매개변수 최적화를 수행하는 것이 좋습니다.
/*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)