This strategy is a quantitative trading system based on the crossover of 13 and 21-period Exponential Moving Averages (EMA). It identifies market trend changes through the observation of short-term and long-term EMA crossovers, generating long positions at golden crosses and short positions at death crosses. The strategy’s unique feature lies in its dynamic color changes, enhancing visual feedback and helping traders identify trading signals more intuitively.
The core logic relies on two EMAs with different periods: a 13-period short-term EMA and a 21-period long-term EMA. When the short-term EMA crosses above the long-term EMA, it forms a golden cross, indicating an uptrend formation and generating a buy signal. Conversely, when the short-term EMA crosses below the long-term EMA, it forms a death cross, indicating a downtrend formation and generating a sell signal. The strategy employs dynamic color display, changing EMA line colors upon crossovers - green for bullish signals and red for bearish signals, providing visual feedback that helps traders quickly assess market conditions.
The Dynamic Dual EMA Crossover Quantitative Strategy combines classic technical analysis with modern visualization techniques. It generates trading signals through EMA crossovers and enhances visual feedback through dynamic color changes, making trading decisions more intuitive. While inherent risks exist, the strategy can become an effective trading tool through proper optimization and risk management. Traders are advised to conduct thorough backtesting and adjust strategy parameters based on market conditions and personal risk tolerance before live implementation.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-03 00:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("EMA Strategy by clf", overlay=true) // Input parameters for EMAs shortEmaLength = input(13, title="Short EMA Length") longEmaLength = input(21, title="Long EMA Length") // Calculate EMAs shortEma = ta.ema(close, shortEmaLength) longEma = ta.ema(close, longEmaLength) // Define the color variable with type var color emaColor = na // Determine the colors for the EMAs based on crossovers if (ta.crossover(shortEma, longEma)) emaColor := color.green else if (ta.crossunder(shortEma, longEma)) emaColor := color.red // Plot EMAs on the chart with dynamic colors plot(shortEma, title="Short EMA", color=emaColor, linewidth=2) plot(longEma, title="Long EMA", color=color.red, linewidth=2) // Generate buy and sell signals longCondition = ta.crossover(shortEma, longEma) shortCondition = ta.crossunder(shortEma, longEma) // Plot buy and sell signals plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL") // Strategy entry and exit strategy.entry("Long", strategy.long, when=longCondition) strategy.close("Long", when=shortCondition) strategy.entry("Short", strategy.short, when=shortCondition) strategy.close("Short", when=longCondition)