EMA Mean Reversion Trading Strategy
Overview
The EMA mean reversion trading strategy opens and closes positions based on the degree to which price diverges from the EMA. It uses the percentage difference between price and EMA as the entry signal and trailing stop loss to manage positions.
Strategy Logic
The strategy uses EMA as the benchmark and calculates the percentage difference between current price and EMA. It goes long when the price is far enough from the EMA (default 9%), and closes position when price gets close enough to the EMA (default 1%). After opening positions, it uses trailing stop loss to lock in profit as it increases.
Specifically, the strategy includes the following components:
-
Calculate EMA. The period (default 200), source (close price) and method (EMA, SMA, RMA, WMA) are configurable.
-
Calculate the percentage difference between current price and EMA. Pay attention to the positive/negative sign.
-
Open positions based on difference threshold. Default long entry is 9% and short entry is 9%.
-
Support ladder entry. The number of rungs and percentage step per rung can be configured.
-
Use trailing stop loss after entry. The threshold to start trailing (default 1% profit) and trailing percentage (default 1%) are configurable.
-
Close positions based on difference threshold. Default exit is 1% for both long and short.
-
Cancel unfilled orders when price reverts to EMA.
-
Configurable stop loss percentage.
-
Support backtesting and live trading.
Advantage Analysis
The advantages of this strategy:
-
Utilize mean reversion concept to trade trend based on EMA deviation. Aligns with trend trading theory.
-
Entry, stop loss, exit parameters are configurable to adapt to different market conditions.
-
Ladder entry allows gradual position build up and reduces cost.
-
Trailing stop locks in profit and manages risk.
-
Highly optimizable by adjusting EMA parameters or entry/exit thresholds.
-
Pine Script allows straightforward use in TradingView.
-
Intuitive charting for observation and analysis.
Risk Analysis
The risks of this strategy:
-
Backtest overfitting risk. Parameter optimization may overfit backtest data and underperform in live trading.
-
EMA failure risk. Price may deviate from EMA for extended periods.
-
Stop loss getting run over risk. Stop loss may get penetrated by volatile moves.
-
High trading frequency leads to higher commission costs.
-
Require longer lookback period. More susceptible to sudden events.
Risk management:
-
Robust parameter selection through optimization and multi-market verification.
-
Reasonable EMA period, not too short or too long.
-
Wider stop loss buffer to prevent getting stopped out prematurely.
-
Less aggressive entry rules to reduce trade frequency.
-
Incorporate additional indicators like volume, Bollinger Bands, RSI to adapt to events.
Optimization Directions
The strategy can be improved in the following aspects:
-
Add filters like volume, Bollinger Bands, RSI to reduce false signals.
-
Add dual EMA for higher probability trend trading.
-
Enhance stop loss with adaptive stops, Chandelier Exits to further limit risk.
-
Add auto parameter optimization to find better parameter sets.
-
Incorporate machine learning for chance of EMA deviation.
-
Consider intraday or overnight position to take advantage of gaps.
-
Integrate stock universe selection for larger capacity.
Conclusion
The EMA mean reversion strategy trades based on the mean reverting behavior of prices around a moving average. It utilizes the statistical properties of EMA rationally to identify trend changes and uses stop loss to control risk. Compared to traditional moving average strategies, it focuses more on dynamic trailing stops than rigid entry and exit rules. The strategy can complement trend following strategies, but requires caution on curve fitting and controlling trade frequency. Further improvements on stop loss and entry quality may lead to better live performance.
- 1

