
다중 평균선 추적 전략과 동적 포지션 관리 시스템은 다중 지수 이동 평균 (EMA) 을 기반으로 한 정량화 거래 전략이다. 이 전략은 5개의 다른 주기 (,12·144·169·576 및 676) 의 EMA 지표를 모니터링함으로써 트렌드 판단, 입시 신호 식별, 배당 구축, 포지션 동적 중지 및 동적 중지 등과 함께 완전한 거래 시스템을 구축한다. 이 전략은 여러 번 포지션을 추가하는 것을 지원하고, 최대 5 개의 거래 포지션을 구축할 수 있으며, 각 포지션에 대한 독립적 인 위험 제어 조치도 있다.
이 전략의 핵심 논리는 다중 EMA 지표들 사이의 위치 관계와 가격과 핵심 EMA의 상호 작용에 기초한다:
트렌드 판단 메커니즘:
출입 신호:
롯데 창고 건설:
동적 정지:
전체적인 위험 통제:
전체적으로, 이 전략은 여러 EMA의 배열을 통해 시장의 추세 방향을 설정하고, 가격과 EMA144의 상호 작용을 통해 진입 시점을 결정하며, 최근 가격 변동 영역을 통해 동적으로 중지 손실 중지 지점을 설정하며, 분할 창고 및 분할 승인을 통해 자금 관리를 최적화하여 최종적으로 완전한 거래 시스템을 형성합니다.
체계화 추세 판단:
정확한 입학 메커니즘:
현명한 재무 관리:
유연한 수익 전략:
엄격한 위험 관리:
매우 적응력이 좋다:
수평선 뒤떨어진 위험:
덩달아 창고 건설에 대한 재정적 압박:
고정 주기 변수의 한계:
대칭 차단의 잠재적인 문제:
입시 조건이 너무 엄격하다:
데이터 의존의 위험:
적응형 매개변수 메커니즘 소개:
입력 신호 필터링 강화:
재정 관리 시스템을 개선하기:
정지 손실 메커니즘을 최적화:
시간 필터를 추가:
트렌드 강도 평가:
다주기 연동 시스템을 구축:
다중 평균선 추적 전략과 동적 포지션 관리 시스템은 구조적이고, 논리적으로 명확한 양적 거래 전략이다. 이 전략은 다중 EMA의 배열 포트폴리오를 통해 트렌드 판단 프레임워크를 구축하고, 가격과 핵심 평균선의 상호 작용을 통해 진입 시기를 결정하며, 분량으로 포지션 및 동적 스톱을 구축하여 정교한 자금 관리 및 위험 통제를 구현한다. 전략의 장점은 체계화된 트렌드 판단, 정교한 진입 메커니즘, 지능적인 자금 관리 및 엄격한 위험 통제에 있다.
그러나, 이 전략은 또한 평평선 뒤떨어짐, 고정 파라미터 제한 및 재무 관리 압력 등의 위험이 있습니다. 전략의 효과를 더욱 향상시키기 위해, 적응 파라미터 메커니즘을 도입, 신호 필터링을 강화, 재무 관리 시스템을 개선, 스톱 로즈 메커니즘을 최적화하고 다중 주기 협동 시스템을 구축하는 등의 최적화 방향을 고려 할 수 있습니다.
전체적으로, 이 전략은 균형 잡힌 트렌드 추적과 위험 통제를 통해 수량 거래에 대한 실행 가능한 강력한 프레임 워크를 제공합니다. 지속적인 최적화와 특정 시장 환경에 대한 매개 변수 조정으로 이 전략은 실제 거래에서 안정적인 성능을 얻을 것으로 예상됩니다.
/*backtest
start: 2024-09-08 00:00:00
end: 2024-12-08 00:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("专业级交易系统", overlay=false, close_entries_rule = "ANY")
x1 = input.float(1.5,"atr倍数",step=0.1)
x2 = input.int(50,"k线数量",step=1)
s1 = strategy.opentrades.entry_price(0)
s2 = strategy.opentrades.entry_price(1)
s3 = strategy.opentrades.entry_price(2)
s4 = strategy.opentrades.entry_price(3)
s5 = strategy.opentrades.entry_price(4)
s6 = strategy.opentrades.entry_price(5)
s7 = strategy.opentrades.entry_price(6)
s8 = strategy.opentrades.entry_price(7)
s9 = strategy.opentrades.entry_price(8)
c = strategy.position_size,o = strategy.opentrades
ema12_len = input.int(12,"EMA12长度")
ema144_len = input.int(144, "EMA144长度")
ema169_len = input.int(169,"EMA169长度")
ema576_len = input.int(376, "EMA576长度")
ema676_len = input.int(576,"EMA676长度")
ema12 = ta.ema(close,ema12_len)
ema144 = ta.ema(close, ema144_len)
ema169 = ta.ema(close, ema169_len)
ema576 = ta.ema(close, ema576_len)
ema676 = ta.ema(close, ema676_len)
e3 = ta.valuewhen(o ==2 and o[1] == 1 and c > 0,bar_index,0)
e4 = ta.valuewhen(o ==3 and o[1] == 2 and c > 0,bar_index,0)
e5 = ta.valuewhen(o ==4 and o[1] == 3 and c > 0,bar_index,0)
le1 = false
le1 := c <= 0 and ema12 > ema144 and ema144 > ema169 and ema169 > ema576 and ema576 > ema676 and low < ema144 and low[1] > ema144 and close > ema169? true : close < ema169 or ema12 < ema144 ? false : le1[1]
le11 = false
le11 := le1 and bar_index - ta.valuewhen(low < ema144 and low[1] > ema144,bar_index,0) < 12 ? true : false
le2 = false
le2 := c > 0 and o == 1 and o[1] == 1 and ema12 > ema144 and ema144 > ema169 and ema169 > ema576 and ema576 > ema676 and low < ema144 and low[1] > ema144 and close > ema169? true : close < ema169 or ema12 < ema144 or o < 1? false : le2[1]
le21 = false
le21 := le2 and bar_index - ta.valuewhen(low < ema144 and low[1] > ema144 and o == 1 and o[1]==1,bar_index,0) < 12 ? true : false
le3 = false
le3 := c > 0 and o == 2 and o[1] == 2 and ema12 > ema144 and ema144 > ema169 and ema169 > ema576 and ema576 > ema676 and low < ema144 and low[1] > ema144 and close > ema169? true : close < ema169 or ema12 < ema144 or o < 2? false : le3[1]
le31 = false
le31 := le3 and bar_index - e3 > 50 and bar_index - ta.valuewhen(low < ema144 and low[1] > ema144 and o == 2 and o[1]==2,bar_index,0) < 12 ? true : false
le4 = false
le4 := c > 0 and o == 3 and o[1] == 3 and ema12 > ema144 and ema144 > ema169 and ema169 > ema576 and ema576 > ema676 and low < ema144 and low[1] > ema144 and close > ema169? true : close < ema169 or ema12 < ema144 or o < 3? false : le4[1]
le41 = false
le41 := le4 and bar_index - e4 > 50 and bar_index - ta.valuewhen(low < ema144 and low[1] > ema144 and o == 3 and o[1]==3,bar_index,0) < 12 ? true : false
le5 = false
le5 := c > 0 and o == 4 and o[1] == 4 and ema12 > ema144 and ema144 > ema169 and ema169 > ema576 and ema576 > ema676 and low < ema144 and low[1] > ema144 and close > ema169? true : close < ema169 or ema12 < ema144 or o < 4? false : le5[1]
le51 = false
le51 := le5 and bar_index - e5 > 50 and bar_index - ta.valuewhen(low < ema144 and low[1] > ema144 and o == 4 and o[1]==4,bar_index,0) < 12 ? true : false
d1 = ta.valuewhen(o == 1 and o[1] == 0 and c > 0,ta.lowest(12),0)
d2 = ta.valuewhen(o == 2 and o[1] == 1 and c > 0,ta.lowest(12),0)
d3 = ta.valuewhen(o == 3 and o[1] == 2 and c > 0,ta.lowest(12),0)
d4 = ta.valuewhen(o == 4 and o[1] == 3 and c > 0,ta.lowest(12),0)
d5 = ta.valuewhen(o == 5 and o[1] == 4 and c > 0,ta.lowest(12),0)
if le11 and close > ema12 and o == 0
strategy.order("l1",strategy.long,comment="第一单")
if c > 0 and o > 0
strategy.exit("出场1","l1",limit = 2*s1- d1,stop= d1,qty_percent = 50)
strategy.exit("出场11","l1",stop= d1)
if le21 and close > ema12 and o == 1
strategy.order("l2",strategy.long,comment="第二单")
if c > 0 and o == 2
strategy.exit("出场2","l2",limit = 2*s2- d2,stop= d2,qty_percent = 50)
strategy.exit("出场21","l2",stop= d2)
if le31 and close > ema12 and o == 2
strategy.order("l3",strategy.long,comment="第三单")
if c > 0 and o == 3
strategy.exit("出场3","l3",limit = 2*s3- d3,stop= d3,qty_percent = 50)
strategy.exit("出场31","l3",stop= d3)
if le41 and close > ema12 and o == 3
strategy.order("l4",strategy.long,comment="第四单")
if c > 0 and o == 4
strategy.exit("出场4","l4",limit = 2*s4- d4,stop= d4,qty_percent = 50)
strategy.exit("出场41","l4",stop= d4)
if le51 and close > ema12 and o == 4
strategy.order("l5",strategy.long,comment="第五单")
if c > 0 and o == 5
strategy.exit("出场5","l5",limit = 2*s5- d5,stop= d5,qty_percent = 50)
strategy.exit("出场51","l5",stop= d5)
bgcolor(le2?color.red:na)
if c > 0 and ema12 < ema144
strategy.close_all("跌破均线全部出场")
//做空
es3 = ta.valuewhen(o ==2 and o[1] == 1 and c < 0,bar_index,0)
es4 = ta.valuewhen(o ==3 and o[1] == 2 and c < 0,bar_index,0)
es5 = ta.valuewhen(o ==4 and o[1] == 3 and c < 0,bar_index,0)
se1 = false
se1 := c >= 0 and ema12 < ema144 and ema144 < ema169 and ema169 < ema576 and ema576 < ema676 and high > ema144 and high[1] < ema144 and close < ema169? true : close > ema169 or ema12 > ema144 ? false : se1[1]
se11 = false
se11 := se1 and bar_index - ta.valuewhen(high > ema144 and high[1] < ema144,bar_index,0) < 12 ? true : false
se2 = false
se2 := c < 0 and o == 1 and o[1] == 1 and ema12 < ema144 and ema144 < ema169 and ema169 < ema576 and ema576 < ema676 and high > ema144 and high[1] < ema144 and close < ema169? true : close > ema169 or ema12 > ema144 or o < 1? false : se2[1]
se21 = false
se21 := se2 and bar_index - ta.valuewhen(high > ema144 and high[1] < ema144 and o == 1 and o[1]==1,bar_index,0) < 12 ? true : false
se3 = false
se3 := c < 0 and o == 2 and o[1] == 2 and ema12 < ema144 and ema144 < ema169 and ema169 < ema576 and ema576 < ema676 and high > ema144 and high[1] < ema144 and close < ema169 ? true : close > ema169 or ema12 > ema144 or o < 2? false : se3[1]
se31 = false
se31 := se3 and bar_index - es3 > 50 and bar_index - ta.valuewhen(high > ema144 and high[1] < ema144 and o == 2 and o[1]==2,bar_index,0) < 12 ? true : false
se4 = false
se4 := c < 0 and o == 3 and o[1] == 3 and ema12 < ema144 and ema144 < ema169 and ema169 < ema576 and ema576 < ema676 and high > ema144 and high[1] < ema144 and close < ema169? true : close > ema169 or ema12 > ema144 or o < 3? false : se4[1]
se41 = false
se41 := se4 and bar_index - es4 > 50 and bar_index - ta.valuewhen(high > ema144 and high[1] < ema144 and o == 3 and o[1]==3,bar_index,0) < 12 ? true : false
se5 = false
se5 := c < 0 and o == 4 and o[1] == 4 and ema12 < ema144 and ema144 < ema169 and ema169 < ema576 and ema576 < ema676 and high > ema144 and high[1] < ema144 and close < ema169 ? true : close > ema169 or ema12 > ema144 or o < 4? false : se5[1]
se51 = false
se51 := se5 and bar_index - es5 > 50 and bar_index - ta.valuewhen(high > ema144 and high[1] < ema144 and o == 4 and o[1]==4,bar_index,0) < 12 ? true : false
ds1 = ta.valuewhen(o == 1 and o[1] == 0 and c < 0 ,ta.highest(12),0)
ds2 = ta.valuewhen(o == 2 and o[1] == 1 and c < 0,ta.highest(12),0)
ds3 = ta.valuewhen(o == 3 and o[1] == 2 and c < 0,ta.highest(12),0)
ds4 = ta.valuewhen(o == 4 and o[1] == 3 and c < 0,ta.highest(12),0)
ds5 = ta.valuewhen(o == 5 and o[1] == 4 and c < 0,ta.highest(12),0)
if se11 and close < ema12 and o == 0
strategy.order("s1",strategy.short,comment="第一单")
if c < 0 and o > 0
strategy.exit("出场1","s1",limit = 2*s1- ds1,stop= ds1,qty_percent = 50)
strategy.exit("出场11","s1",stop= ds1)
if se21 and close < ema12 and o == 1
strategy.order("s2",strategy.short,comment="第二单")
if c < 0 and o == 2
strategy.exit("出场2","s2",limit = 2*s2- ds2,stop= ds2,qty_percent = 50)
strategy.exit("出场21","s2",stop= ds2)
if se31 and close < ema12 and o == 2
strategy.order("s3",strategy.short,comment="第三单")
if c < 0 and o == 3
strategy.exit("出场3","s3",limit = 2*s3- ds3,stop= ds3,qty_percent = 50)
strategy.exit("出场31","s3",stop= ds3)
if se41 and close < ema12 and o == 3
strategy.order("s4",strategy.short,comment="第四单")
if c < 0 and o == 4
strategy.exit("出场4","s4",limit = 2*s4- ds4,stop= ds4,qty_percent = 50)
strategy.exit("出场41","s4",stop= ds4)
if se51 and close < ema12 and o == 4
strategy.order("s5",strategy.short,comment="第五单")
if c < 0 and o == 5
strategy.exit("出场5","s5",limit = 2*s5- ds5,stop= ds5,qty_percent = 50)
strategy.exit("出场51","s5",stop= ds5)
bgcolor(se1?color.red:na)
if c < 0 and ema12 > ema144
strategy.close_all("跌破均线全部出场")
kaiguan = input.bool(true,"均线开关")
plot(ema12,force_overlay=true)
plot(ema144, "EMA144", color=color.new(#008000, 0),force_overlay=true)
plot(ema169, "EMA169", color=color.red,force_overlay=true)
plot(kaiguan?ema576:na,color=color.yellow,force_overlay=true)
plot(kaiguan?ema676:na,color=color.yellow,force_overlay=true)
//plotshape(series=entrySignal,title="买入信号",location=location.belowbar,color=color.new(color.green, 0),style=shape.labelup,text="BUY",textcolor=color.new(color.white, 0))