This is a dual moving average trading strategy based on the Detrended Synthetic Price (DSP). DSP is a function that is in phase with the dominant cycle of real price data, obtained by subtracting a half-cycle EMA from the quarter-cycle EMA. When DSP crosses above the upper band or below the lower band, unilateral trades are taken.
Calculate the 1/2-cycle HL average xHL2 of price.
Compute the 1/4-cycle EMA (xEMA1) and 1/2-cycle EMA (xEMA2) of xHL2 based on Length.
Obtain DSP by subtracting xEMA2 from xEMA1.
Set upper and lower band parameters, go long when DSP crosses above upper band, and go short when crossing below lower band.
The reverse parameter can switch between long and short direction.
Advantages of this strategy:
DSP captures the dominant price cycle, avoiding misdirection from minor cycles.
The dual EMA design effectively tracks dominant cycle changes.
Simple upper/lower bands avoid over-trading.
Easily switch between long/short using reverse parameter, adaptable to different market environments.
No complex parameter optimization required, simple and practical.
Main risks:
Improper DSP cycle setting may miss the dominant cycle.
Band width needs optimization, otherwise over-trading may occur.
Fixed cycle design has poor adaptability to violent market changes.
Trading on DSP alone leaves strategy vulnerable to whipsaws.
Lack of stop loss may lead to significant losses.
Improvements:
Optimize parameters to find best cycle combination.
Add dynamic bands based on volatility.
Incorporate trend and volatility filters to reduce false signals.
Add stop loss or trailing stop mechanisms to control risk.
Test across multiple instruments for universality.
Introduce machine learning for adaptive DSP cycle optimization.
Overall this is a very simple and practical dual moving average trading strategy. It is built on solid cycle analysis foundations, with DSP effectively tracking the dominant cycle. With refinements in parameter optimization, stop losses, filter conditions and more, it can become a reliable quantitative trading strategy.
/*backtest start: 2023-09-11 00:00:00 end: 2023-09-13 02:00:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=2 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 20/03/2017 // Detrended Synthetic Price is a function that is in phase with the // dominant cycle of real price data. This DSP is computed by subtracting // a half-cycle exponential moving average (EMA) from the quarter cycle // exponential moving average. // See "MESA and Trading Market Cycles" by John Ehlers pages 64 - 70. // // You can change long to short in the Input Settings // Please, use it only for learning or paper trading. Do not for real trading. //////////////////////////////////////////////////////////// strategy(title="D_DSP (Detrended Synthetic Price)", shorttitle="D_DSP") Length = input(14, minval=1) SellBand = input(25) BuyBand = input(-25) reverse = input(false, title="Trade reverse") hline(0, color=blue, linestyle=line) hline(SellBand, color=red, linestyle=line) hline(BuyBand, color=green, linestyle=line) xHL2 = hl2 xEMA1 = ema(xHL2, Length) xEMA2 = ema(xHL2, 2 * Length) xEMA1_EMA2 = xEMA1 - xEMA2 pos = iff(xEMA1_EMA2 > SellBand, 1, iff(xEMA1_EMA2 < BuyBand, -1, nz(pos[1], 0))) possig = iff(reverse and pos == 1, -1, iff(reverse and pos == -1, 1, pos)) if (possig == 1) strategy.entry("Long", strategy.long) if (possig == -1) strategy.entry("Short", strategy.short) barcolor(possig == -1 ? red: possig == 1 ? green : blue ) plot(xEMA1_EMA2, color=blue, title="D_DSP")