AI Volume Divergence Trader
- Experts
-
Fadi Hassan Khaled Ghanem
MQL4/MQL5 developer based in Jordan. I have published 169 MetaTrader 5 products on the MQL5 Market (about 8,800 downloads in total).
What I build:
- Custom Expert Advisors from your own trading rules
- Indicators, alerts and multi-timeframe dashboards - Version: 2.0
- Updated: 22 September 2026
Overview
AI Volume Divergence Trader is an automated Expert Advisor built around a volume-price divergence engine. It combines On-Balance Volume (OBV) analysis with RSI extremity filtering and a proprietary AI-inspired confidence scoring model to identify high-probability reversal zones where price action and underlying volume flow disagree with each other.
How It Works
The EA continuously scans recent and prior price swings on the selected timeframe:
- It detects bullish divergence when price prints a lower low while OBV prints a higher low over the same window, signalling fading selling pressure.
- It detects bearish divergence when price prints a higher high while OBV prints a lower high, signalling fading buying pressure.
- Each divergence signal is filtered by RSI extremity (oversold for bullish setups, overbought for bearish setups), so trades are only considered near statistically stretched conditions.
- An AI-inspired 0-100 confidence score blends the strength of the OBV/price divergence with the RSI extremity distance from its threshold. Trades are only opened once this composite score clears a configurable minimum confidence level.
- An optional EMA200 "sanity filter" uses a loose 2% tolerance band (not a hard cross) to avoid opening trades that fight an extremely strong prevailing trend.
Risk Management
- ATR-based stop loss and take profit, automatically adapting to current market volatility.
- Optional trailing stop that respects the broker's minimum stop and freeze distances at all times.
- Margin check before every trade (via OrderCalcMargin against free margin, with a safety buffer) to help avoid over-leveraging.
- Lot size is automatically normalized to the broker's volume step, minimum, and maximum.
- Session-time gate and spread filter to avoid trading during illiquid or abnormally wide-spread conditions.
- One trade per new bar (no tick-by-tick over-trading).
Input Parameters
- InpMagicNumber - unique identifier for this EA's trades.
- InpTimeframe - timeframe used for divergence analysis.
- InpMaxSpreadPoints - maximum allowed spread (in points) for new trades.
- InpRecentWindow / InpPriorWindow - bar windows used to compare recent vs. prior price/OBV swings.
- InpRsiPeriod / InpRsiOversold / InpRsiOverbought - RSI extremity filter settings.
- InpMinConfidence - minimum AI confidence score (0-100) required to open a trade.
- InpUseEmaFilter / InpEmaTrendPeriod - optional loose trend sanity filter.
- InpLotSize - base lot size (automatically normalized).
- InpAtrPeriod / InpSlAtrMult / InpTpAtrMult - ATR-based stop loss / take profit multipliers.
- InpUseTrailing / InpTrailAtrMult / InpTrailStepPoints - trailing stop configuration.
How to Read a Divergence Trade
- Bullish setup: price makes a lower low, but OBV makes a higher low, and RSI is in the oversold zone. This means sellers pushed price lower with less volume behind them. The EA only buys if the confidence score is above InpMinConfidence.
- Bearish setup: price makes a higher high, but OBV makes a lower high, and RSI is in the overbought zone. Buyers are pushing with less volume, so the EA looks for a sell.
- Why it sometimes does nothing: a divergence without an RSI extreme, a confidence score below your minimum, a spread above InpMaxSpreadPoints, or price far beyond the EMA200 band will all block the trade. Long quiet periods are normal for a reversal EA.
- Tuning tip: start in the Strategy Tester on the symbol and timeframe you plan to trade. Raise InpMinConfidence for fewer, more selective trades; widen InpRecentWindow / InpPriorWindow on higher timeframes. Then forward-test on a demo account.
Important Notes
This Expert Advisor does not guarantee profits. Past performance, backtests, and illustrative concept diagrams are not indicative of future results. Always test thoroughly on a demo account before live deployment, and use appropriate risk settings for your account size and risk tolerance.
Risk & Requirements at a Glance
- At most one new trade per bar - no tick-by-tick over-trading.
- Every trade uses an ATR-based Stop Loss and Take Profit; optional trailing stop respects broker stop/freeze levels.
- Fixed lot size (normalized to broker volume limits), margin check with safety buffer before every trade, Max Spread and session filters.
- Entries require a minimum confidence score plus RSI and optional EMA200 conditions.
- Runs on the symbol/timeframe you choose - test that exact pair and timeframe in the Strategy Tester first.
- Defaults are a starting point, not tuned for your broker - test on demo with real ticks first. Results are not guaranteed.
Frequently Asked Questions
- Does it use grid or martingale? No. Every trade uses a fixed lot size (normalized to your broker's limits) with an ATR-based Stop Loss and Take Profit. Lots are never multiplied after a loss.
- Which symbol and timeframe should I use? It runs on the chart you attach it to. There is no single "best" pair - test your exact symbol and timeframe in the Strategy Tester with real ticks, then forward-test on demo.
- Why is it not opening trades? Divergence setups are selective. A trade needs a divergence, an RSI extreme, a confidence score above InpMinConfidence, an acceptable spread and (if enabled) the EMA200 condition. Long quiet periods are normal. Lower InpMinConfidence only after testing.
- Can I run it on several charts at once? Yes, attach it to each chart separately. Use a different magic number per chart and keep total risk in mind, since each chart trades independently.
- Is it suitable for prop-firm challenges? It has a fixed lot, a stop loss on every trade and spread/session filters, but it does not track a prop firm's daily loss or max drawdown rules. A prop-firm version with those limits is available as a custom order.
- Is there an MT4 version or alerts-only mode? Not in this free version (MT5 only). Both can be built as a custom version - see below.
Need a Custom Version?
I can adapt this EA to your own rules - extra filters, a different money management (for example risk-% lot sizing), prop-firm daily loss / drawdown limits, or an MT4 version. Send me a private message here on MQL5 (or offer me a personal order via MQL5 Freelance) with your requirements, and I will reply within 24 hours with whether it is doable and the estimated scope. If you find this free version useful, please leave a review - it helps a lot.
More free tools from the same developer
- AI Swing High Low Labels Indicator - labels HH/LH/HL/LL swings, so you can see on the chart which swing points a volume/price divergence is being measured between.
- AI Supply and Demand Zones Indicator - draws supply and demand zones from base-and-departure price action - useful to check whether a divergence signal appears at a zone or in the middle of nowhere.
- AI Liquidity Sweep Reversal Trader - another free reversal EA with a different trigger (a sweep of a recent high/low and a close back inside), if you want to compare a second reversal approach in the Strategy Tester.
