
This is a mean reversion trading strategy that capitalizes on significant deviations between price and the 50-period Exponential Moving Average (EMA). Specifically designed for volatile markets, the strategy aims to profit by buying when prices fall substantially below the EMA and selling when they recover above it. The strategy primarily tracks the percentage difference between price and EMA, triggering trading signals when this difference exceeds specific thresholds.
The core logic is based on the mean reversion theory, which suggests that while prices may deviate from their mean in the short term, they tend to revert to it over time. The strategy uses a 50-period EMA as a reference point for the mean price. When the price falls significantly below this average (over 10%), it’s considered a buying opportunity. When the price recovers above the EMA and shows a profit, it triggers a sell signal. The calculation is as follows:
1. Uses a 50-period EMA as the baseline
2. Calculates the percentage deviation of price from EMA: diff_perct = ((ema20 - close) / ema20) * 100
3. Calculates the percentage deviation of high price from EMA: diff_perct2 = ((high - ema20) / ema20) * 100
4. When diff_perct > 10 (i.e., price is more than 10% below EMA), a buy signal is triggered
5. When diff_perct2 > 0 (i.e., high price is above EMA) and the current trade is profitable (profit > 1), a sell signal is triggered
The 50-Period EMA Divergence Mean Reversion Strategy is an automated trading system based on technical analysis that seeks trading opportunities by capturing significant deviations between price and moving averages. The strategy is simple and intuitive, suitable for markets with higher volatility, but also carries certain risks, especially in strong trending markets. By adding stop-loss mechanisms, dynamic parameter adjustments, and multi-indicator confirmations, the strategy’s robustness and profitability can be significantly enhanced. Ideally, this strategy would serve as part of a more comprehensive trading system rather than being used in isolation.
/*backtest
start: 2024-03-26 00:00:00
end: 2025-03-25 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("SUIBTC 2H - EMA dip public",overlay=true,initial_capital=100,default_qty_value=100, default_qty_type = strategy.cash,process_orders_on_close=false,calc_on_every_tick=false)
BuyTrigger = input.bool(false)
SellTrigger = input.bool(false)
src = input(open, title="Source")
offset = input.int(title="Offset", defval=5, minval=-500, maxval=500)
ema20 = ta.ema(close, 50)
plot(ema20, title="ema20", color=color.yellow, linewidth=3)
diff_perct = ((ema20 - close) / ema20) * 100
diff_perct2 = ((high - ema20) / ema20) * 100
if ( diff_perct > 10)
BuyTrigger := true
if( diff_perct2 > 0 and strategy.openprofit > 1)
SellTrigger := true
notInTrade = strategy.position_size <= 0
inTrade = strategy.position_size > 0
timeSinceLastTrade_ms = time - strategy.opentrades.entry_time(0)
if (BuyTrigger and notInTrade )
strategy.order("long", strategy.long , oca_name = 'audusdt' , when = BuyTrigger ,limit = open, comment = "buy: SUIBTC EMA Dip")
if (SellTrigger and inTrade )
strategy.close(id="long" , qty_percent = 100, comment = "sell: SUIBTC EMA Dip")