이것은 트렌드를 따르는 전략으로, 3 개의 기하급수적인 이동 평균 (EMA) 과 방향 이동 지표 (DMI) 및 이동 평균 컨버전스 디버전스 (MACD) 지표를 결합하여 트렌드 방향을 결정하고 구매/판매 신호를 생성합니다. 주요 구성 요소는 EMA 크로스오버 신호, 트렌드 강도를 나타내는 DMI 및 모멘텀 확인을위한 MACD입니다.
핵심 논리는 총 추세를 파악하기 위해 M5 시간 틀에 계산된 3개의 EMA - 34, 89, 200 - 에 의존합니다. 34개 기간 EMA는 단기 방향을 제시하고, 89개 EMA와 200개 EMA는 각각 중장기 추세를 정의합니다.
구매 신호는 다음과 같은 경우에 발동됩니다.
판매 신호는 다음 경우에 생성됩니다.
추가 확인은 MACD 지표에서 입력 전에 나옵니다.
이 전략은 몇 가지 주요 장점을 가지고 있습니다.
고려해야 할 주요 위험은:
완화 방법:
전략의 추가 개선:
/*backtest start: 2023-01-18 00:00:00 end: 2024-01-24 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("2 EMA di+ Buy Sell, strategy ", overlay=true) // Define the EMA calculation function ema(src, length) => ta.ema(src, length) // Calculate and plot EMA on M5 ema34_M5 = ema(close, 34) ema89_M5 = ema(close, 89) ema200_M5 = ema(close, 200) // Plot EMAs plot(ema34_M5, color=color.green, title="EMA 34 M5", linewidth=2) plot(ema89_M5, color=color.blue, title="EMA 89 M5", linewidth=2) plot(ema200_M5, color=color.black, title="EMA 200 M5", linewidth=2) // Define DMI parameters len = input(14, title="DI Length") up = ta.change(high) down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) trur = ta.rma(ta.tr, len) plusDI = 100 * ta.rma(plusDM, len) / trur minusDI = 100 * ta.rma(minusDM, len) / trur // Calculate ADX adxValue = 100 * ta.rma(math.abs(plusDI - minusDI) / (plusDI + minusDI == 0 ? 1 : plusDI + minusDI), len) // Define MACD parameters fastLength = input(12, title="Fast Length") slowLength = input(26, title="Slow Length") signalLength = input(9, title="Signal Length") // Calculate MACD [macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalLength) // Create buy/sell conditions buyCondition = close > ema34_M5 and plusDI > 17 and adxValue > minusDI sellCondition = close < ema34_M5 and minusDI > 17 and adxValue > plusDI // Strategy logic strategy.entry("Buy", strategy.long, when = buyCondition) strategy.entry("Sell", strategy.short, when = sellCondition) // Create alerts for buy/sell signals alertcondition(buyCondition, title="Buy Signal", message="Buy Signal") alertcondition(sellCondition, title="Sell Signal", message="Sell Signal") // Plot buy/sell arrows on the price chart bgcolor(buyCondition ? color.new(color.green, 90) : sellCondition ? color.new(color.red, 90) : na) plotarrow(buyCondition ? 1 : sellCondition ? -1 : na, colorup=color.new(color.green, 0), colordown=color.new(color.red, 0), offset=-1)