Reversal Trading Strategy with EMA Crossover and Bollinger Bands

Author: ChaoZhang, Date: 2024-02-21 16:12:18



This strategy calculates two EMA lines with different periods to determine the long-term and short-term trend of the stock price. It also incorporates the upper and lower rails of the Bollinger Bands to judge whether the stock price is in an overbought or oversold state, as signals for entry and exit. It combines multiple technical indicators such as moving averages and Bollinger Bands to locate market reversal points, which belongs to a typical trend-following and reversal trading strategy.

Strategy Logic

  1. Calculate the fast EMA (50-period) and slow EMA (200-period). The fast EMA crossing above the slow EMA is a buy signal, while the fast EMA crossing below is a sell signal.

  2. Calculate the 20-period Bollinger Bands upper and lower rails.

  3. When the price breaks through the BB upper rail, it is considered an overbought signal to go short. When the price breaks through the BB lower rail, it is considered an oversold signal to go long.

  4. Combine the EMA crossovers and BB breakout signals to determine entries and exits.

The above logic is the main way this strategy identifies trading signals. It goes long when the fast EMA crosses over the slow EMA or when the price breaks the BB lower rail. It goes short when the fast EMA crosses below the slow EMA or when the price breaks the BB upper rail.

Advantage Analysis

This is a typical strategy combining multiple technical indicators, which considers both long-term and short-term price trends, as well as overbought and oversold conditions. The main advantages are:

  1. EMA crossovers can effectively determine long-term and short-term trends.

  2. Bollinger Bands can identify overbought and oversold zones to avoid chasing tops and bottoms.

  3. Combining indicators improves robustness and avoids false signals.

  4. Backtest results can be further enhanced through parameter tuning.

Risk Analysis

There are some risks with this strategy:

  1. EMA may have lagging effect, missing best entry points.

  2. Improper BB parameter selection may miss trends.

  3. Too many combined signals increases complexity.

  4. Parameters may fail when market regimes change.


  1. Optimize parameters adaptive to markets.

  2. Add stop loss to control risks.

  3. Test different EMA and BB parameter combinations.

  4. Further enhancements such as combining with RSI.

Optimization Directions

There is strong potential to optimize this strategy:

  1. Test more EMA and BB parameter combinations.

  2. Incorporate other indicators like MACD, KDJ, RSI.

  3. Add trailing stop loss.

  4. Test the strategy across different time frames.

  5. Combine with unusual volume for more signals.

Through robust backtesting across different parameters and indicators, the strategy can be further improved for stability and profitability.


This strategy builds upon the two most important technical indicators EMA and Bollinger Bands to identify long-term/short-term trends and overbought/oversold levels, making it highly practical. Further parameter tuning and combining more indicators can lead to better results. It reflects the key idea in quantitative trading strategies to assess the market condition, design rules, and optimize the strategy. With continuous testing and enhancement, this strategy has the potential to become a reliable algorithmic trading system.

start: 2024-01-21 00:00:00
end: 2024-02-20 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]

strategy("Reversal Patterns, EMA Crossover, and Bollinger Bands", shorttitle="RP-EMABB", overlay=true)

// Input parameters
emaShortPeriod = input(50, title="Short EMA Period", minval=1)
emaLongPeriod = input(200, title="Long EMA Period", minval=1)
bbLength = input(20, title="Bollinger Bands Length", minval=1)
bbMultiplier = input(2.0, title="Bollinger Bands Multiplier", minval=0.1, maxval=5.0)

// Calculate EMAs
emaShort = ema(close, emaShortPeriod)
emaLong = ema(close, emaLongPeriod)

// Calculate Bollinger Bands
bbUpper = sma(close, bbLength) + bbMultiplier * stdev(close, bbLength)
bbLower = sma(close, bbLength) - bbMultiplier * stdev(close, bbLength)

// EMA Crossover and Crossunder
emaCrossover = crossover(emaShort, emaLong)
emaCrossunder = crossunder(emaShort, emaLong)

// Bollinger Bands Crossing
bbUpperCross = crossover(close, bbUpper)
bbLowerCross = crossunder(close, bbLower)

// Buy and Sell signals
strategy.entry("Buy", strategy.long, when=emaCrossover or bbLowerCross)
strategy.entry("Sell", strategy.short, when=emaCrossunder or bbUpperCross)

// Plot EMAs on the chart
plot(emaShort,, title="50 EMA")
plot(emaLong,, title="200 EMA")

// Plot Bollinger Bands
plot(bbUpper,, title="Bollinger Bands Upper")
plot(bbLower,, title="Bollinger Bands Lower")

// Highlight Buy and Sell signals on the chart
bgcolor(emaCrossover or bbLowerCross ? : na, transp=90)
bgcolor(emaCrossunder or bbUpperCross ? : na, transp=90)