
이 전략은 빠르고 느린 지수 이동 평균 ((EMA) 의 교차에 기반한 트렌드 추적 거래 시스템이다. 이 전략은 가격과 쌍평준의 위치 관계를 확인함으로써 더 신뢰할 수 있는 매매 신호를 생성한다. 이 전략은 피드백 기간 설정 기능을 내장하여 특정 시간 범위에서 전략의 성과를 평가하는 것을 용이하게 한다.
전략은 10주기 및 20주기 EMA를 핵심 지표로 사용한다. 빠른 EMA가 느린 EMA를 상대로 올라갈 때, 그리고 닫기 가격은 두 개의 평균선 위에있을 때, 다중 신호를 유발한다. 빠른 EMA가 느린 EMA를 상대로 내려갈 때, 그리고 닫기 가격은 두 개의 평균선 아래에있을 때, 공백 신호를 유발한다. 이 이중 확인 메커니즘은 신호의 신뢰성을 높인다.
이것은 명확한 구조와 논리적으로 엄격한 트렌드 추적 전략이다. 쌍평선 교차와 결합된 가격 확인 메커니즘을 통해 신호의 시기적절성과 신뢰성을 효과적으로 균형을 맞추고 있다. 전략은 좋은 확장성을 가지고 있으며, 최적화를 통해 성능을 더욱 향상시킬 수 있다. 중·장기 트렌드 추적을 위한 기본 전략 프레임워크에 적합하다.
/*backtest
start: 2024-02-21 00:00:00
end: 2024-10-01 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"BNB_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BFXGold
//@version=5
strategy("BFX Buy and Sell", overlay=true)
// Inputs
ema_fast_length = input.int(10, title="Fast EMA Length")
ema_slow_length = input.int(20, title="Slow EMA Length")
// Calculate EMAs
ema_fast = ta.ema(close, ema_fast_length)
ema_slow = ta.ema(close, ema_slow_length)
// Confirmation candles
confirmation_above = close > ema_fast and close > ema_slow
confirmation_below = close < ema_fast and close < ema_slow
// Crossovers with confirmation
long_condition = ta.crossover(ema_fast, ema_slow) and confirmation_above
short_condition = ta.crossunder(ema_fast, ema_slow) and confirmation_below
// Plot signals
if (long_condition )
label.new(bar_index, low, text="BUY", style=label.style_label_up, color=color.new(color.green, 0), textcolor=color.white)
if (short_condition)
label.new(bar_index, high, text="SELL", style=label.style_label_down, color=color.new(color.red, 0), textcolor=color.white)
// Strategy execution for backtesting
if (long_condition)
strategy.entry("Long", strategy.long)
if (short_condition)
strategy.entry("Short", strategy.short)
// Plot EMAs
plot(ema_fast, title="Fast EMA (10)", color=color.blue, linewidth=1)
plot(ema_slow, title="Slow EMA (20)", color=color.orange, linewidth=1)