
이 전략은 다중 지수 이동 평균 (EMA) 에 기반한 트렌드 추적 시스템이다. 이 전략은 단기 및 장기 EMA 그룹의 평균을 계산하여 시장의 추세를 식별하고 평행선이 교차할 때 거래 신호를 발생시킨다. 이 전략은 위험을 제어하고 이익을 잠금하기 위해 스톱 손실 메커니즘을 통합한다.
이 전략은 6개의 단기 EMA ((3, 5, 8, 10, 12, 15주기) 와 6개의 장기 EMA ((30, 35, 40, 45, 50, 60주기) 를 사용한다. 이러한 평균선을 각각 평균화함으로써 더 부드러운 단기 및 장기 트렌드 지표를 얻는다. 단기 평균선이 장기 평균선을 상향으로 통과하면 더 많은 신호가 발생하며, 단기 평균선이 장기 평균선을 하향으로 통과하면 빈 신호가 발생한다.
이것은 잘 구성된 트렌드 추적 전략으로, 여러 개의 평균선을 조합하여 비교적 신뢰할 수 있는 거래 신호를 제공합니다. 약간의 지연 위험이 있지만, 합리적인 스톱 스톱 손실 설정과 권장되는 최적화 방향을 통해 전략의 전반적인 성능이 더욱 향상 될 수 있습니다. 이 전략은 특히 명백한 추세가있는 시장 환경에서 사용하기에 적합합니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Pavan Guppy Strategy", shorttitle="Pavan Avg", overlay=true,
default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Short-term EMAs
shortEMA1 = ta.ema(close, 3)
shortEMA2 = ta.ema(close, 5)
shortEMA3 = ta.ema(close, 8)
shortEMA4 = ta.ema(close, 10)
shortEMA5 = ta.ema(close, 12)
shortEMA6 = ta.ema(close, 15)
// Long-term EMAs
longEMA1 = ta.ema(close, 30)
longEMA2 = ta.ema(close, 35)
longEMA3 = ta.ema(close, 40)
longEMA4 = ta.ema(close, 45)
longEMA5 = ta.ema(close, 50)
longEMA6 = ta.ema(close, 60)
// Average short-term EMAs
shortAvg = (shortEMA1 + shortEMA2 + shortEMA3 + shortEMA4 + shortEMA5 + shortEMA6) / 6.0
// Average long-term EMAs
longAvg = (longEMA1 + longEMA2 + longEMA3 + longEMA4 + longEMA5 + longEMA6) / 6.0
// Plot averaged EMAs
plot(shortAvg, color=color.green, linewidth=2, title="Averaged Short-term EMAs")
plot(longAvg, color=color.red, linewidth=2, title="Averaged Long-term EMAs")
// Define the target and stop loss percentages
takeProfitPerc = 10
stopLossPerc = 5
// Generate buy signal when shortAvg crosses above longAvg
if ta.crossover(shortAvg, longAvg)
strategy.entry("Buy", strategy.long)
// Generate sell signal when shortAvg crosses below longAvg
if ta.crossunder(shortAvg, longAvg)
strategy.entry("Sell", strategy.short)
// Calculate take profit and stop loss prices for long trades
longTakeProfit = close * (1 + (takeProfitPerc / 100.0))
longStopLoss = close * (1 - (stopLossPerc / 100.0))
// Set take profit and stop loss for long positions
strategy.exit("Take Profit/Stop Loss", from_entry="Buy", limit=longTakeProfit, stop=longStopLoss)
// Calculate take profit and stop loss prices for short trades
shortTakeProfit = close * (1 - takeProfitPerc / 100.0)
shortStopLoss = close * (1 + stopLossPerc / 100.0)
// Set take profit and stop loss for short positions
strategy.exit("Take Profit/Stop Loss", from_entry="Sell", limit=shortTakeProfit, stop=shortStopLoss)