AI Heikin Ashi Reversal 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.1
- Updated: 22 September 2026
Overview
AI Heikin-Ashi Reversal Trader is a fully automated Expert Advisor for MetaTrader 5. It reconstructs synthetic Heikin-Ashi candles from the live price feed and looks for a color-flip reversal signal after an extended directional streak. Every potential signal is scored by an AI-inspired confidence engine before any trade is considered.
Risk & Requirements at a Glance
- One position at a time per symbol/magic number - no stacking of additional positions.
- Every trade has an ATR-based stop loss and take profit, with a minimum stop distance in points (optional ATR trailing stop).
- Fixed base lot size that you set for your account, normalized to your broker's volume limits; a free-margin check with a safety buffer runs before every order.
- Signals only after a minimum Heikin-Ashi streak, ADX +DI/-DI confirmation, a minimum confidence score and an EMA200 distance filter.
- Maximum spread filter and session-time filter with an edge buffer.
- The default inputs are a starting point, not settings tuned for your broker or symbol. Test in the Strategy Tester and on a demo account first - results are not guaranteed.
How It Works
- The EA builds Heikin-Ashi candles internally from the raw OHLC data of the selected symbol and timeframe - no external indicator file is required.
- It watches for a color flip (for example, a run of red candles turning green) that follows a minimum streak of same-color candles, treated as a sign of an exhausted directional move.
- Each flip is cross-checked against the ADX indicator's directional lines (+DI / -DI) to confirm the new direction has underlying momentum before it is treated as a signal.
- A 0-100 AI-inspired confidence score combines the length of the prior streak and the strength of the directional separation. A trade is only considered once the score clears a configurable minimum threshold.
- An EMA200 sanity filter helps avoid taking a reversal signal too far against the prevailing longer-term trend.
Risk Management
- ATR-based stop loss and take profit distances that adapt to current market volatility.
- Optional ATR-based trailing stop. Before adjusting the stop loss, the EA checks the distance between price and the current take profit to avoid broker rejections when price is already close to the target.
- A margin check runs before every trade request, comparing the estimated required margin against free margin with a safety buffer.
- Lot size is automatically normalized to the broker's minimum, maximum and step volume constraints.
- A configurable session-time filter with an edge buffer, plus a maximum spread filter, help the EA stand aside in unfavorable conditions.
- One position at a time per symbol/magic number.
Input Parameters
- InpMagicNumber - unique identifier for this EA's trades.
- InpTimeframe - working timeframe used to build the Heikin-Ashi candles and indicators.
- InpMaxSpreadPoints - maximum allowed spread, in points, before a new trade is skipped.
- InpEdgeBufferSeconds - buffer, in seconds, kept clear from the session open/close edges.
- InpMinStreak - minimum number of same-color Heikin-Ashi candles required before a flip is considered a signal.
- InpMaxStreakNorm - streak length that maps to the maximum streak-based confidence score.
- InpAdxPeriod - period used for the ADX / +DI / -DI calculation.
- InpAdxDiNorm - directional separation value that maps to the maximum ADX-based confidence score.
- InpMinConfidence - minimum AI confidence score (0-100) required before a trade is opened.
- InpEmaTrendPeriod - period of the EMA used for the longer-term trend sanity filter.
- InpEmaSanityAtrMult - maximum ATR-multiple distance from the EMA allowed for a reversal signal.
- InpLotSize - base lot size before broker volume normalization.
- InpAtrPeriod, InpSlAtrMult, InpTpAtrMult - ATR period and multipliers used to size the stop loss and take profit.
- InpMinStopPoints - minimum stop distance in points, regardless of ATR.
- InpUseTrailing, InpTrailAtrMult, InpTrailStepPoints - trailing stop settings.
Important Notes
This Expert Advisor automates a clearly defined trading logic based on Heikin-Ashi candle construction and directional strength confirmation. It does not guarantee profit, and no result - hypothetical or otherwise - is a reliable indicator of future performance. Please test on a demo account first, use position sizing appropriate to your account, and be aware that trading leveraged instruments carries a risk of loss.
Custom Version
Need a custom version? I can adapt this EA to your own rules - extra filters, a session/time filter, different money management, prop-firm daily-loss and 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'll reply within 24 hours with whether it's doable and the estimated scope. Please test it in the Strategy Tester first, and message me first if you have any question about the settings.

I am looking for a reversal trading EA. However, this one shows only two trades this whole year. Not useful at all.