Skip to content

Free MT5 Expert Advisor

Order Block Retest EA

MT5 Expert Advisor that trades the first return into a fresh order block, by market or limit order, with the stop placed beyond the block.

Smart moneyv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Non-repainting signals Stop-loss on every trade
Strategy
After a large bullish candle breaks recent highs, it marks the last bearish candle before it as a bullish order block and buys the first return into it; bearish blocks are traded the same way in reverse.
Risk model
1% of balance per trade (configurable), stop-loss beyond the block on every order, one position or pending order per symbol and magic number

What it does

Order Block Retest EA looks for a strong impulse candle and marks the last opposite-coloured candle before it as an order block, a zone where many traders expect price to react if it comes back. The EA trades only the first return into each fresh block, with the stop placed just beyond the block.

You can choose to enter at market once a candle touches the block and closes without breaking it, or to rest a limit order at the block edge as soon as the block forms.

How it works

On each new bar the EA checks the last closed candle:

  1. Displacement: a bullish candle whose body is at least 1.5 times ATR and which closes above the highs of the previous 3 bars.
  2. Block: the most recent bearish candle within the 5 bars before it. Its high and low become the block top and bottom. The impulse must have closed above the block top. If the trend filter is on, the close must also be above the 200 EMA.
  3. Freshness: the block is watched for up to 60 bars. A close below the block bottom invalidates it. The first candle whose low reaches the block top uses it up, whatever happens next.
  4. Market mode: if that touching candle closes above the block bottom, the EA buys with the stop at the block bottom minus 0.2 ATR and a 2 R target.
  5. Limit mode: a buy limit is placed at the block top with the same stop and target. It is deleted when the block is invalidated, when it is older than the block lifetime, or when another position is open.

Bearish blocks are the mirror image. Only one bullish and one bearish block are tracked at a time; a newer block replaces the older one.

How to use it

Use the EA on M15 to H4 charts where impulses are clear. Market mode waits for some confirmation and usually gets a worse price; limit mode gets the block edge but also fills when price slices straight through. Raising the displacement multiple filters out weak impulses. Read the Experts tab to see each block the EA marks.

Settings

InputDefaultWhat it changes
Displacement body (x ATR)1.5Strength of the impulse candle
Break bars3Prior bars the impulse must close beyond
Block search bars5How far back to look for the opposite candle
Block max age (bars)60Lifetime of a block and its limit order
Entry modeMarketMarket on rejection close or limit at block edge
Stop buffer (x ATR)0.2Room beyond the block
Max stop (x ATR)3.0Skips very wide blocks
Trend EMAon, 200Direction filter
Risk % / Fixed lots1.0 / 0Position sizing
Take-profit (R)2.0Target distance (0 = none)
Max spread / hours30 points / 7 to 20Entry filters
Break-even / Trailingon at 1 R / offTrade management

Limitations

Order blocks are an interpretation, not a law of the market, and many blocks fail. Wide blocks create wide stops and therefore small positions. Limit orders can fill outside your trading hours and during news spikes. The rules use closed candles, so nothing repaints, but entries in market mode come one candle after the touch.

Before you run it live

Test both entry modes in the Strategy Tester and on a demo account first. Check that your broker accepts pending orders at the distances the EA uses (stops level) and how spread behaves at your trading hours. Keep risk small while you learn how the EA behaves, and review risk-reward ratio basics before changing the target. Trading carries a substantial risk of loss.

Key inputs

Key inputs of Order Block Retest EA
InputDefaultDescription
Displacement body (x ATR)1.5Minimum body of the impulse candle that creates a block.
Break bars3The impulse must close beyond the highs or lows of this many prior bars.
Entry modeMarket on rejection closeMarket order after a candle touches the block, or a limit order at the block edge.
Block max age (bars)60Blocks and their limit orders expire after this many bars.
Stop buffer (x ATR)0.2Extra distance beyond the block for the stop-loss.
Risk per trade (%)1.0Share of balance risked between entry and stop-loss.

Educational tools, not advice. Automated trading can lose money quickly. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 expert advisors