
이 전략은 다양한 유형의 평균을 계산하여 (Simple Moving Average SMA, Index Moving Average EMA, Hull Moving Average HMA, and Quantitative Weighted Moving Average VWMA) 그리고 그 교차점을 찾아, 시장 추세를 판단하고 추세를 따라합니다. 더 짧은 평균이 아래에서 더 긴 평균을 통과하면 구매 신호를 생성합니다. 더 짧은 평균이 위에서 아래에서 더 긴 평균을 통과하면 판매 신호를 생성합니다.
이 전략은 주로 두 개의 다른 평행선 사이의 관계를 비교하여 시장 움직임을 판단한다. 구체적으로, 입력 파라미터를 통해 두 개의 평행선의 유형과 길이를 설정한다. 그 중 첫 번째 평행선의 길이는 장기 흐름을 나타내고; 두 번째 평행선의 길이는 현재 단기 흐름을 나타낸다.
단기평균선이 아래에서 장기평균선을 통과할 때, 단기 경향이 강해지고, 물가가 상승 경향에 들어서, 따라서 이 교차점에서 구매 신호를 발산한다. 반대로, 단기평균선이 위로부터 장기평균선을 통과할 때, 단기 경향이 약해지고, 물가가 하향 경향에 들어서, 따라서 이 교차점에서 판매 신호를 발산한다.
이런 평평한 평평한 판단을 통해 시장의 추세에 따라 거래한다.
위험 해결 방법:
이 전략은 평선 교차 판단 주요 트렌드의 고전적 사고를 기반으로, 다른 평선의 조합을 통해 유연하게 적용된다. 전략 논리는 간단하고, 구현하기 쉽고, 자동화 거래에 적합하다. 전반적으로 이 전략은 실용성이 있지만, 몇 가지 개선 최적화 공간도 있다. 매개 변수 최적화, 다른 필터 판단을 추가하는 등의 방법을 통해 전략 성능을 지속적으로 향상시킬 수 있다.
/*backtest
start: 2023-12-31 00:00:00
end: 2024-01-30 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
//study(title="MA Crossover Strategy", overlay = true)
strategy("MA Crossover Strategy", overlay=true)
src = input(close, title="Source")
price = request.security(syminfo.tickerid, timeframe.period, src)
ma1 = input(25, title="1st MA Length")
type1 = input("HMA", "1st MA Type", options=["SMA", "EMA", "HMA", "VWMA"])
ma2 = input(7, title="2nd MA Length")
type2 = input("HMA", "2nd MA Type", options=["SMA", "EMA", "HMA", "VWMA"])
f_hma(_src, _length)=>
_return = wma((2*wma(_src, _length/2))-wma(_src, _length), round(sqrt(_length)))
price1 = if (type1 == "SMA")
sma(price, ma1)
else
if (type1 == "EMA")
ema(price, ma1)
else
if (type1 == "VWMA")
vwma(price, ma1)
else
f_hma(price, ma1)
price2 = if (type2 == "SMA")
sma(price, ma2)
else
if (type2 == "EMA")
ema(price, ma2)
else
if (type2 == "VWMA")
vwma(price, ma2)
else
f_hma(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)
longCondition = crossover(price1, price2)
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = crossunder(price1, price2)
if (shortCondition)
strategy.entry("Short", strategy.short)