The Dual EMA Price Swing strategy judges market sentiment and momentum by calculating the difference between two EMAs of different periods. An up-crossing of the difference value above 0 is a bullish signal. A down-crossing below 0 is a bearish signal.
The strategy is simple and easy to use, judging market momentum and direction through EMA difference. However, it also has some laggingness and cannot timely capture turning points.
The core indicator of the Dual EMA Price Swing strategy is APO, namely Absolute Price Oscillator, representing the difference between two EMAs. Its formula is:
APO = EMA(short period) − EMA(long period)
Specifically, the APO in this strategy is calculated as:
xShortEMA = ema(close price, LengthShortEMA)
xLongEMA = ema(close price, LengthLongEMA)
xAPO = xShortEMA − xLongEMA
Where LengthShortEMA and LengthLongEMA represent the cycle lengths of the short-term and long-term EMAs respectively.
Several key judgment rules of APO:
Determine market sentiment and entry timing based on the real-time value of APO.
The Dual EMA Price Swing Strategy has the following main advantages:
The Dual EMA Price Swing Strategy also has some risks, mainly in:
We can cope with and reduce these risks by applying reasonable stop loss to reduce single loss; optimizing parameters to adapt cycles; combining other indicators to filter signals and improve strategy stability.
The Dual EMA Price Swing Strategy can be optimized in the following aspects:
In summary, the Dual EMA Price Swing Strategy judges market sentiment by calculating the APO difference between two EMAs. The strategy signal is simple and practical, but also has some drawbacks. We can optimize it through parameter tuning, adding filters, setting stops and more. Easy to use for beginners, also with great potential for expansions. Suitable for quant trading learners to study and apply.
/*backtest start: 2023-02-19 00:00:00 end: 2024-02-25 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=2 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 30/05/2017 // The Absolute Price Oscillator displays the difference between two exponential // moving averages of a security's price and is expressed as an absolute value. // How this indicator works // APO crossing above zero is considered bullish, while crossing below zero is bearish. // A positive indicator value indicates an upward movement, while negative readings // signal a downward trend. // Divergences form when a new high or low in price is not confirmed by the Absolute Price // Oscillator (APO). A bullish divergence forms when price make a lower low, but the APO // forms a higher low. This indicates less downward momentum that could foreshadow a bullish // reversal. A bearish divergence forms when price makes a higher high, but the APO forms a // lower high. This shows less upward momentum that could foreshadow a bearish reversal. // // 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="Absolute Price Oscillator (APO) Backtest", shorttitle="APO") LengthShortEMA = input(10, minval=1) LengthLongEMA = input(20, minval=1) reverse = input(false, title="Trade reverse") hline(0, color=gray, linestyle=line) xPrice = close xShortEMA = ema(xPrice, LengthShortEMA) xLongEMA = ema(xPrice, LengthLongEMA) xAPO = xShortEMA - xLongEMA pos = iff(xAPO > 0, 1, iff(xAPO < 0, -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(xAPO, color=blue, title="APO")