
이 전략은 20일 지수 이동 평균 ((EMA) 에 기반하여 채널을 구축하고, 가격이 채널 위를 넘어서면 더 많이 하고, 가격이 채널 아래를 넘어서면 더 적게 하며, 트렌드 추적 전략에 속한다.
위험 해결 방법:
이 전략은 전반적으로 간단하고 실용적이며, EMA 채널을 기반으로 구성되어 있으며, 전형적인 트렌드 추적 전략에 속한다. 돌파구 신호의 특징이 있지만, 또한 일정한 오해의 위험이 존재한다. 최적화 매개 변수, 필터를 추가하는 등의 방법으로 전략 효과를 향상시킬 수 있으며, 추가 테스트 및 최적화를 할 가치가 있다.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("EMA Channel Strategy with Alerts", shorttitle="EMA Channel", overlay=true)
// Define EMA length
emaLength = 20
// Calculate EMA values
emaHigh = ema(high, emaLength)
emaLow = ema(low, emaLength)
// Define the condition for a buy signal
buyCondition = crossover(close, emaHigh)
// Define the condition for a sell signal
sellCondition = crossunder(close, emaLow)
// Plot the EMA lines
plot(emaHigh, color=color.green, title="EMA High")
plot(emaLow, color=color.red, title="EMA Low")
// Plot buy and sell signals
plotshape(buyCondition, style=shape.triangleup, location=location.belowbar, color=color.green, title="Buy Signal")
plotshape(sellCondition, style=shape.triangledown, location=location.abovebar, color=color.red, title="Sell Signal")
// Strategy
strategy.entry("Buy", strategy.long, when=buyCondition)
strategy.close("Buy", when=sellCondition)
// Define and trigger alerts
alertcondition(buyCondition, title="Buy Alert", message="Buy signal - Price crossed above EMA High")
alertcondition(sellCondition, title="Sell Alert", message="Sell signal - Price crossed below EMA Low")