
This strategy is a trend-following system based on multiple Exponential Moving Averages (EMAs). It identifies market trends by calculating the averages of short-term and long-term EMA groups and generates trading signals at crossovers. The strategy incorporates take-profit and stop-loss mechanisms to control risk and secure profits.
The strategy employs 6 short-term EMAs (3, 5, 8, 10, 12, 15 periods) and 6 long-term EMAs (30, 35, 40, 45, 50, 60 periods). By averaging these EMAs separately, it creates smoother short-term and long-term trend indicators. Long positions are initiated when the short-term average crosses above the long-term average, while short positions are taken when the short-term average crosses below. Each trade is managed with a 10% take-profit and 5% stop-loss level.
This is a well-structured trend-following strategy that provides relatively reliable trading signals through the combination of multiple EMAs. While it carries some inherent lag risks, the overall performance can be further enhanced through appropriate take-profit and stop-loss settings and the suggested optimization directions. The strategy is particularly suitable for markets exhibiting clear trends.
/*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)