
이 전략은 3개의 다른 주기의 이동 평균을 계산하여 가격 돌파구와 결합하여 거래 신호를 형성함으로써 전형적인 트렌드 추적 전략에 속한다. 이 전략은 시장의 중간 기간 트렌드를 추적하기 위해 고안되었으며, 동적으로 조정된 파라미터를 통해 다양한 품종과 거래 환경에 적용할 수 있다.
이 전략은 세 개의 이동 평균을 포함합니다: MA1, MA2 및 MA3 ᆞ MA1 및 MA2 사이에 거래 통로가 형성되며, 그 교차는 거래 신호를 제공합니다. MA3는 신호를 필터링합니다.
빠른 평균 MA1이 중기 평균 MA2을 뚫을 때, 단기 추세가 강해지는 것을 나타냅니다. 이 때 가격이 장기 평균 MA3보다 높으면 다중 신호가 발생한다. 반대로, MA1이 MA2을 뚫고 MA3보다 가격이 낮으면 다중 신호가 발생한다.
MA3의 역할은 단기 시장의 잡음을 필터링하고, 트렌드가 중장기 단계로 진입하는 것을 확인한 후에만 신호를 생성한다. 이 전략은 세 개의 이동 평균의 파라미터를 동적으로 조정하여 다양한 시장에서 최적의 파라미터 조합을 찾을 수 있다.
MA 주기를 조정하여 다양한 품종을 선택할 수 있으며, 패러미터를 최적화 할 수 있습니다. 단독 손실을 제어하기 위해 손해 중지 전략을 최적화하고, 다른 기술 지표와 결합하여 신호의 유효성을 확인하여 잘못된 신호의 가능성을 줄일 수 있습니다.
이 전략은 3개의 이동 평균을 계산하고 교차적으로 거래 신호를 생성하는 것을 관찰하여 빠르고 느리게 협력하는 사고를 사용하여 추세를 판단하는 전형적인 트렌드 추적 전략이다. 이 전략은 매개 변수 최적화를 통해 다른 품종에 적용할 수 있지만, 교착과 놓친 전환점이 발생할 위험이 있다. 향후에는 다른 기술 지표의 신호 유효성을 판단하고, 동적 매개 변수 최적화 메커니즘을 개발하는 등의 방법으로 최적화하여 전략을 더 탄력하게 만들 수 있다.
/*backtest
start: 2023-01-16 00:00:00
end: 2024-01-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Meesemoo
//@version=4
strategy("Custom MA Strategy Tester", overlay = true)
MA1Period = input(13, title="MA1 Period")
MA1Type = input(title="MA1 Type", defval="SMA", options=["RMA", "SMA", "EMA", "WMA", "HMA", "DEMA", "TEMA"])
MA1Source = input(title="MA1 Source", type=input.source, defval=close)
MA1Visible = input(title="MA1 Visible", type=input.bool, defval=true)
MA2Period = input(50, title="MA2 Period")
MA2Type = input(title="MA2 Type", defval="SMA", options=["RMA", "SMA", "EMA", "WMA", "HMA", "DEMA", "TEMA"])
MA2Source = input(title="MA2 Source", type=input.source, defval=close)
MA2Visible = input(title="MA2 Visible", type=input.bool, defval=true)
MA3Period = input(200, title="MA3 Period")
MA3Type = input(title="MA3 Type", defval="SMA", options=["RMA", "SMA", "EMA", "WMA", "HMA", "DEMA", "TEMA"])
MA3Source = input(title="MA3 Source", type=input.source, defval=close)
MA3Visible = input(title="MA3 Visible", type=input.bool, defval=true)
ShowCrosses = input(title="Show Crosses", type=input.bool, defval=true)
MA1 = if MA1Type == "SMA"
sma(MA1Source, MA1Period)
else
if MA1Type == "EMA"
ema(MA1Source, MA1Period)
else
if MA1Type == "WMA"
wma(MA1Source, MA1Period)
else
if MA1Type == "RMA"
rma(MA1Source, MA1Period)
else
if MA1Type == "HMA"
wma(2*wma(MA1Source, MA1Period/2)-wma(MA1Source, MA1Period), round(sqrt(MA1Period)))
else
if MA1Type == "DEMA"
e = ema(MA1Source, MA1Period)
2 * e - ema(e, MA1Period)
else
if MA1Type == "TEMA"
e = ema(MA1Source, MA1Period)
3 * (e - ema(e, MA1Period)) + ema(ema(e, MA1Period), MA1Period)
MA2 = if MA2Type == "SMA"
sma(MA2Source, MA2Period)
else
if MA2Type == "EMA"
ema(MA2Source, MA2Period)
else
if MA2Type == "WMA"
wma(MA2Source, MA2Period)
else
if MA2Type == "RMA"
rma(MA2Source, MA2Period)
else
if MA2Type == "HMA"
wma(2*wma(MA2Source, MA2Period/2)-wma(MA2Source, MA2Period), round(sqrt(MA2Period)))
else
if MA2Type == "DEMA"
e = ema(MA2Source, MA2Period)
2 * e - ema(e, MA2Period)
else
if MA2Type == "TEMA"
e = ema(MA2Source, MA2Period)
3 * (e - ema(e, MA2Period)) + ema(ema(e, MA2Period), MA2Period)
MA3 = if MA3Type == "SMA"
sma(MA3Source, MA3Period)
else
if MA3Type == "EMA"
ema(MA3Source, MA3Period)
else
if MA3Type == "WMA"
wma(MA3Source, MA3Period)
else
if MA3Type == "RMA"
rma(MA3Source, MA3Period)
else
if MA3Type == "HMA"
wma(2*wma(MA3Source, MA3Period/2)-wma(MA3Source, MA3Period), round(sqrt(MA3Period)))
else
if MA3Type == "DEMA"
e = ema(MA3Source, MA3Period)
2 * e - ema(e, MA3Period)
else
if MA3Type == "TEMA"
e = ema(MA3Source, MA3Period)
3 * (e - ema(e, MA3Period)) + ema(ema(e, MA3Period), MA3Period)
p1 = plot(MA1Visible ? MA1 : na, color=color.green, linewidth=1)
p2 = plot(MA2Visible ? MA2 : na, color=color.yellow, linewidth=1)
p3 = plot(MA3Visible ? MA3 : na, color=color.red, linewidth=2)
fill(p1, p2, color.silver, transp=80, title="Fill")
start = timestamp(2019, 1, 1, 1, 0)
end = timestamp(2025, 1, 1, 1, 0)
if time >= start and time <= end
longCondition = crossover(MA1, MA2) and close > MA3
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = crossunder(MA1, MA2) and close < MA3
if (shortCondition)
strategy.entry("Short", strategy.short)