
이중 이동 평균 돌파 전략은 좀 더 전형적인 트렌드 추적 전략이다. 그것은 두 개의 다른 주기 이동 평균을 계산하고, 그것을 교차하여 구매 및 판매 신호로 사용하여, 시장 트렌드의 방향과 강도를 포착한다.
이 전략은 주로 두 개의 이동 평균을 기반으로 한다. 첫 번째 이동 평균의 주기가 짧아서 가격 변화에 더 빠르게 반응할 수 있다. 두 번째 이동 평균의 주기가 길어서 일부 잡음을 필터링 할 수 있다. 단기 이동 평균 위에 장기 이동 평균을 가로질러서는 구매 신호로 간주되며, 단기 이동 평균 아래에 장기 이동 평균을 가로질러서는 판매 신호로 간주된다.
구체적으로, 이 전략은 10주기 지수 이동 평균 ((price1)) 과 20주기 지수 이동 평균 ((price2)) 을 계산한다. 현재 K선의 개시 가격과 닫기 가격이 두 이동 평균보다 높으면 구매 신호를 발생시키고, 현재 K선의 개시 가격과 닫기 가격이 두 이동 평균보다 낮으면 판매 신호를 발생시킨다.
이런 디자인을 통해, 트렌드가 형성되기 시작했을 때 일찍 시장에 진입하여 트렌드를 추적할 수 있고, 트렌드가 반전될 때, 빨리 시장에서 빠져나와 위험을 효과적으로 제어할 수 있다.
이 전략은 전체적으로 비교적 간단하고 실용적이며, 쌍평평선 교차원 원칙을 통해 트렌드를 포착하는 것으로, 양적 거래의 기본 전략이다. 그러나 이 전략은 또한 일정한 위험이 존재하며, 다른 시장 환경에 적응하기 위해 추가적으로 최적화 할 필요가 있다. 매개 변수 조정, 손해 중지 장치, 신호 필터링 등에서 최적화 할 여지가 있으며, 전략을 더 안정적으로 신뢰할 수 있다.
/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
//study(title="MA River CC v1", overlay = true)
strategy("MA River CC v1", overlay=true)
src = input(close, title="Source")
price = request.security(syminfo.tickerid, timeframe.period, src)
ma1 = input(10, title="1st MA Length")
type1 = input("EMA", "1st MA Type", options=["SMA", "EMA"])
ma2 = input(20, title="2nd MA Length")
type2 = input("EMA", "2nd MA Type", options=["SMA", "EMA"])
price1 = if (type1 == "SMA")
sma(price, ma1)
else
ema(price, ma1)
price2 = if (type2 == "SMA")
sma(price, ma2)
else
ema(price, ma2)
//plot(series=price, style=line, title="Price", color=black, linewidth=1, transp=0)
plot(series=price1, style=line, title="1st MA", color=blue, linewidth=2, transp=0)
plot(series=price2, style=line, title="2nd MA", color=green, linewidth=2, transp=0)
buy_entry = (open>price1 and open>price2) and (close>price1 and close>price2)
sell_entry = (open<price1 and open<price2) and (close<price1 and close<price2)
buy_close = sell_entry
sell_close = buy_entry
//longCondition = crossover(price1, price2)
if(buy_entry)
strategy.entry("Long", strategy.long)
if(sell_entry)
strategy.entry("Short", strategy.short)
strategy.close("Long" , when=buy_close)
strategy.close("Short",when=sell_close)