
이 전략은 여러 층의 이동 평균 ((SMA) 에 기반한 트렌드 추적 시스템으로, 정밀한 분기 크로스 검출 기술을 결합한다. 20, 50, 100, 200 주기의 이동 평균의 계층적 관계를 통해 시장의 추세를 결정하고, 실시간 가격과 이동 평균의 크로스 를 사용하여 거래 신호를 유발한다. 전략은 다른 시간대와 거래 시간의 보편성을 충분히 고려하여 설계되었으며, 다양한 시간 주기의 차트에서 작동할 수 있다.
이 전략은 3층의 트렌드 필터링 메커니즘을 사용하며, 50주기 평균선이 100주기 평균선 위에 있고, 100주기 평균선이 200주기 평균선 위에 있을 때만 상승세를 확인하고, 반대로 하향세를 확인한다. 입력 신호는 50주기 평균선과 가격의 교차에 기초하여, 분기 데이터를 사용하여 정확한 교차 검사를 수행하고, 현재 가격 행동과 전 K선의 위치 관계를 비교하여 교차가 발생하는 시기를 결정한다. 출력 신호는 20주기 평균선과 가격의 관계에 의해 결정되며, 가격이 20주기 평균선 시간선을 돌파했을 때 평소 포지 신호를 유발한다.
이것은 구조가 완전하고, 논리가 명확한 트렌드 추적 전략이며, 여러 층의 이동 평균의 조합을 통해 신호의 신뢰성을 보장하고, 트렌드에 대한 효과적인 추적을 구현합니다. 전략의 설계는 실용성과 보편성을 충분히 고려하여 다양한 시장 환경에서 사용하기에 적합합니다. 이 전략은 추가로 최적화 및 개선함으로써 실제 거래에서 더 나은 성능을 얻을 수 있습니다.
/*backtest
start: 2024-02-22 00:00:00
end: 2024-06-25 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Multi-SMA Strategy - Core Signals", overlay=true)
// ———— Universal Inputs ———— //
int smaPeriod1 = input(20, "Fast SMA")
int smaPeriod2 = input(50, "Medium SMA")
bool useTickCross = input(true, "Use Tick-Precise Crosses")
// ———— Timezone-Neutral Calculations ———— //
sma20 = ta.sma(close, smaPeriod1)
sma50 = ta.sma(close, smaPeriod2)
sma100 = ta.sma(close, 100)
sma200 = ta.sma(close, 200)
// ———— Tick-Precise Cross Detection ———— //
golden_cross = useTickCross ?
(high >= sma50 and low[1] < sma50[1]) :
ta.crossover(sma20, sma50)
death_cross = useTickCross ?
(low <= sma50 and high[1] > sma50[1]) :
ta.crossunder(sma20, sma50)
// ———— Trend Filter ———— //
uptrend = sma50 > sma100 and sma100 > sma200
downtrend = sma50 < sma100 and sma100 < sma200
// ———— Entry Conditions ———— //
longCondition = golden_cross and uptrend
shortCondition = death_cross and downtrend
// ———— Exit Conditions ———— //
exitLong = ta.crossunder(low, sma20)
exitShort = ta.crossover(high, sma20)
// ———— Strategy Execution ———— //
strategy.entry("Long", strategy.long, when=longCondition)
strategy.entry("Short", strategy.short, when=shortCondition)
strategy.close("Long", when=exitLong)
strategy.close("Short", when=exitShort)
// ———— Clean Visualization ———— //
plot(sma20, "20 SMA", color.new(color.blue, 0))
plot(sma50, "50 SMA", color.new(color.red, 0))
plot(sma100, "100 SMA", color.new(#B000B0, 0), linewidth=2)
plot(sma200, "200 SMA", color.new(color.green, 0), linewidth=2)
// ———— Signal Markers ———— //
plotshape(longCondition, "Long Entry", shape.triangleup, location.belowbar, color.green, 0)
plotshape(shortCondition, "Short Entry", shape.triangledown, location.abovebar, color.red, 0)
plotshape(exitLong, "Long Exit", shape.xcross, location.abovebar, color.blue, 0)
plotshape(exitShort, "Short Exit", shape.xcross, location.belowbar, color.orange, 0)