
This strategy is a trading system based on multiple Exponential Moving Average (EMA) crossover signals, combining EMAs of different periods with an ATR-based dynamic stop-loss mechanism. The strategy utilizes EMAs of 10, 39, and 73 periods as primary signal indicators, while incorporating a 143-period higher timeframe EMA as a trend filter, and implements dynamic stop-loss and take-profit targets using the ATR indicator.
The core logic is based on multiple EMA crossovers and trend confirmation. A long signal is generated when the short-term EMA (10-period) crosses above the medium-term EMA (39-period), and price is above both the long-term EMA (73-period) and higher timeframe EMA (143-period). Conversely, a short signal is generated when the short-term EMA crosses below the medium-term EMA, and price is below both longer-term EMAs. The strategy implements a risk-reward ratio of 1:2 using 1x ATR for stop-loss and 2x ATR for take-profit targets.
This strategy builds a trading system combining trend following and risk management through multiple EMA crossovers and ATR-based dynamic stops. Its main strengths lie in multiple timeframe confirmation mechanisms and dynamic position management, while being mindful of ranging market and lag risks. Strategy stability and profitability can be further enhanced through volume confirmation, trend strength filtering, and other optimizations. In practical application, parameters should be adjusted according to different market environments and trading instrument characteristics.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced EMA Crossover Strategy", overlay=true)
// Define the EMA lengths
ema_short_length = 10
ema_long_length = 39
ema_filter_length = 73
ema_higher_tf_length = 143
// Calculate the EMAs
ema_short = ta.ema(close, ema_short_length)
ema_long = ta.ema(close, ema_long_length)
ema_filter = ta.ema(close, ema_filter_length)
ema_higher_tf = request.security(syminfo.tickerid, "D", ta.ema(close, ema_higher_tf_length))
// Calculate ATR for volatility-based stop loss and take profit
atr_length = 14
atr = ta.atr(atr_length)
// Plot the EMAs
plot(ema_short, title="EMA 10", color=color.blue)
plot(ema_long, title="EMA 35", color=color.red)
plot(ema_filter, title="EMA 75", color=color.orange)
plot(ema_higher_tf, title="EMA Higher TF", color=color.purple)
// EMA crossover conditions with EMA 75 and higher timeframe EMA filter
longCondition = ta.crossover(ema_short, ema_long) and close > ema_filter and close > ema_higher_tf
shortCondition = ta.crossunder(ema_short, ema_long) and close < ema_filter and close < ema_higher_tf
// Execute long trade with dynamic stop loss and take profit
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Long", limit=close + 2 * atr, stop=close - 1 * atr)
// Execute short trade with dynamic stop loss and take profit
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Short", limit=close - 2 * atr, stop=close + 1 * atr)
// Plot signals on the chart
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")