Hi everyone,
I’m sharing this strategy I’ve been working on recently. It’s a mean reversion setup designed for the DAX working on M30 (with proper optimization it gives algo great results on the Nasdaq). The strategy targets reversals using a combination of indicators:
– Bollinger Bands for volatility and price extremes
– VWAP for intraday price reference
– EMAs for trend direction
– Higher Highs pattern confirmation
The strategy looks for oversold conditions near the lower Bollinger Band, waiting for a VWAP breakout to confirm the reversal. It includes automatic position closure before US market open.
While testing this strategy, I noticed the trade frequency is lower than expected. Although the logic behind seems to be great, I believe there’s room for improvement. Rather than keeping it to myself, I decided to share it as it could serve as a good foundation for further development for those who are interested in dedicating some time.
Potential areas for enhancement:
– Fine-tuning the BB parameters
– Adding volume filters
– Implementing more sophisticated exit rules
Feel free to modify and build upon this base (and share the final result if you want).
P.S: As always, please backtest thoroughly before using with real money.
//——————————————//
// Reversal Catcher — Thibauld Robin — FOR DAX M30
//——————————————//
// Initialization
ONCE pos = 0
BBlength = 20
BBmult = 1.5
fastEMA = 21
slowEMA = 50
rsiLength = 14
overbought = 70
oversold = 30
// Bollinger Bands
bbMA = AVERAGE[BBlength](close)
bbDev = SQRT(SUMMATION[BBlength]((close – bbMA)*(close – bbMA))/BBlength)
BBupper = bbMA + (bbDev * BBmult)
BBlower = bbMA – (bbDev * BBmult)
// EMAs
ema21 = TEMA[21](close)
ema50 = TEMA[50](close)
// VWAP
IF day<>day[1] THEN
d=1
VWAP=typicalprice
ELSE
d=d+1
IF volume > 0 THEN
VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
ENDIF
ENDIF
// Trend
upTrend = ema21 > ema50
// HH/LL
hhLLong = low > low[1] AND high > high[1] AND close > high[1]
// Entries
vwapBreakout = close crosses over VWAP
longCond = Low[1] < BBlower[1] AND close > BBlower AND close < BBupper AND hhLLong AND upTrend AND vwapBreakout
// Exits
exitLong = (close > BBupper) OR (ema21 crosses under ema50)
// Trading Orders
IF longCond AND pos = 0 THEN
BUY 1 SHARES AT MARKET
pos = 1
SET STOP LOSS low[1]
ENDIF
// Exits
IF pos = 1 AND exitLong THEN
SELL AT MARKET
pos = 0
ENDIF
// Close before US open
IF TIME >= 150000 AND pos <> 0 THEN
IF pos = 1 THEN
SELL AT MARKET
ENDIF
pos = 0
ENDIF