This strategy is a quantitative trading approach based on the crossover between the Detrended Price Oscillator (DPO) and its 4-period Exponential Moving Average (EMA). The core concept is to capture market trend changes by comparing the relationship between DPO and its 4-period EMA to generate buy and sell signals. The strategy is particularly effective on 4-hour and above timeframes, especially when using Heikin Ashi candles.
The core logic includes the following key steps:
The DPO-EMA Trend Crossover Strategy is a structurally simple but effective quantitative trading strategy. By combining the detrended oscillator with moving averages, the strategy effectively captures market trend changes. While inherent risks exist, the strategy maintains practical value through proper optimization and risk management measures. For medium to long-term traders, this strategy represents a viable trading approach worth consideration.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-04 00:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("DPO 4,24 Strategy", shorttitle="DPO Strategy", overlay=true) // Define a fixed lookback period and EMA length length = 24 ema_length = 4 // Calculate the Simple Moving Average (SMA) of the closing prices sma = ta.sma(close, length) // Calculate the shifted SMA value shifted_sma = sma[length / 2 + 1] // Calculate the Detrended Price Oscillator (DPO) dpo = close - shifted_sma // Calculate the 4-period Exponential Moving Average (EMA) of the DPO dpo_ema = ta.ema(dpo, ema_length) // Generate buy and sell signals based on crossovers buy_signal = ta.crossover(dpo, dpo_ema) sell_signal = ta.crossunder(dpo, dpo_ema) // Overlay buy and sell signals on the candlestick chart plotshape(series=buy_signal, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(series=sell_signal, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL") // Strategy entry and exit conditions if (buy_signal) strategy.entry("Buy", strategy.long) if (sell_signal) strategy.close("Buy")