This strategy is a quantitative trading system based on the crossover of dual Exponential Moving Averages (EMA). It utilizes a short-term EMA (14 periods) and a long-term EMA (100 periods) to capture market trend transition points by determining entry timing through the intersection of short-term and long-term moving averages. Buy signals are generated when the short-term EMA crosses above the long-term EMA, and sell signals are generated when the opposite occurs. This strategy is particularly suitable for traders looking to position themselves at the beginning of trend reversals.
The core logic of the strategy is built on momentum changes in price trends. The short-term EMA is more sensitive to price changes, while the long-term EMA better filters market noise and reflects the primary trend. When the short-term moving average crosses above the long-term moving average, it indicates strengthening short-term momentum and a possible uptrend; when the short-term moving average crosses below the long-term moving average, it suggests weakening momentum and a potential downtrend. The strategy uses ta.crossover and ta.crossunder functions to accurately capture these crossing points and execute position operations at appropriate times.
The Dynamic EMA Trend Crossover Entry Quantitative Strategy is a classic and practical trend-following system. By combining short-term and long-term exponential moving averages, the strategy effectively captures market trend transition opportunities. While there are risks of lag and false signals, stable trading results can still be achieved through appropriate parameter optimization and risk control measures. The strategy’s simplicity and scalability make it an excellent foundation framework for quantitative trading.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-11 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("EMA Crossover Strategy", overlay=true) // Input for EMAs shortEmaLength = input(14, title="Short EMA Length") longEmaLength = input(100, title="Long EMA Length") // Calculate EMAs shortEma = ta.ema(close, shortEmaLength) longEma = ta.ema(close, longEmaLength) // Plot EMAs plot(shortEma, color=color.blue, title="9 EMA") plot(longEma, color=color.red, title="100 EMA") // Historical Signal Tracking var float lastBuyPrice = na var float lastSellPrice = na // Buy and Sell Signals buySignal = ta.crossover(shortEma, longEma) sellSignal = ta.crossunder(shortEma, longEma) // Track last buy and sell prices if (buySignal) lastBuyPrice := close if (sellSignal) lastSellPrice := close // Plot buy and sell signals on the chart plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL") // Strategy Logic if (buySignal) strategy.entry("Buy", strategy.long) if (sellSignal) strategy.close("Buy")