Pillar Guide · MetaTrader 5 Structure

Order Block Indicator MT5: Validation, Non-Repainting Checks & Setup

A technical breakdown of how an order block indicator in MT5 identifies institutional displacement zones, why free Smart Money scripts often repaint, how to audit boxes in Strategy Tester Visual Mode, and how to integrate buffer reads safely with disciplined risk sizing.

13 min read
Editorial Policy

Direct Answer — Order Block Indicator MT5

An order block indicator for MT5 highlights the last opposite-direction candle before an impulsive price move that breaks market structure. Because many free scripts repaint unconfirmed swings or incomplete higher-timeframe bars, traders should verify zone persistence in MT5 Strategy Tester Visual Mode, read closed-bar buffers safely, and size stops conservatively.

1. What an Order Block Is in Institutional & Price-Action Analysis

In modern Smart Money Concepts (SMC) and price-action trading, an order block (OB) denotes a specific consolidation candle—or tight cluster of opposing candles—sitting immediately at the origin of an aggressive directional price expansion. Unlike subjective hand-drawn trendlines, order block definitions map directly to OHLC candle geometry, which explains why programmers build dedicated order block indicator MT5 scripts to scan and plot them automatically.

Bullish Order Block (Demand Origin)

Defined structurally as the last bearish (down-close) candle printed right before a strong upward impulse leg that breaks above a recent swing high. Traders typically mark the candle's High-to-Low range (or Open to Low body/wick zone) as a potential future demand reference on pullbacks.

Bearish Order Block (Supply Origin)

Defined structurally as the last bullish (up-close) candle printed right before a steep downward impulse leg that breaks below a recent swing low. Traders project the High-to-Low (or High to Open) rectangle forward as a potential supply reference when price retraces.

From a market microstructure standpoint, why do traders watch these origin candles? Large institutional execution desks rarely clear full multi-million-unit currency inventory in one market click without causing severe slippage. Instead, resting liquidity absorbs opposing flow at an inflection point before price breaks imbalance sharply away. When price later returns to that origin band, remaining unfilled limit interest or short-covering exits can create localized reaction bounces.

It is essential, however, to reject promotional hype: an order block is not an impenetrable institutional force field, and no indicator can read proprietary bank order books from decentralized spot-FX candle feeds. Order blocks fail frequently during strong macro breakouts or opposing central-bank catalysts—in which case a cleanly closed-through order block often flips polarity into a Breaker Block.

Order Blocks vs. Classic Supply/Demand Zones vs. Breaker Blocks

Although traders sometimes use the phrases interchangeably, MT5 structure scripts distinguish three zone archetypes explicitly. A classic Supply or Demand zone frequently wraps multi-candle rally-base-rally or drop-base-drop consolidations regardless of whether a prior swing was broken. By contrast, a strict Order Block isolates the single final opposing candle immediately preceding displacement that creates a confirmed Break of Structure.

When an unmitigated bullish order block fails to hold support and a subsequent candle closes decisively beneath its low, that invalidated demand candle flips into a bearish Breaker Block. Tracking mitigation and polarity flips faithfully—rather than erasing broken boxes—gives you honest context during trending markets and prevents survivorship bias when evaluating an indicator across older chart history.

2. Validation Criteria: Displacement, BOS & Fair Value Gap Confluence

The single biggest flaw in naive order block indicator MT5 scripts is marking every alternating bearish/bullish candle pair on the chart. Within a few days of M15 data, your terminal becomes unreadable with overlapping rectangles. Rigorous implementations require explicit confluence filters before drawing a validated zone:

Validation FactorBullish OB ConditionBearish OB ConditionAnalytical Purpose
Opposing Origin CandleLast bearish (down-close) candle—or tight opposing cluster—before an upward surge.Last bullish (up-close) candle—or tight opposing cluster—before a downward impulse.Defines objective Open/Close or High/Low box bounds so automated scripts do not redraw zones subjectively.
Impulsive DisplacementSeries of wide-body bullish candles expanding beyond recent ATR norms (e.g., >= 1.5x ATR).Series of wide-body bearish candles expanding downward with minimal opposing lower/upper wicks.Separates genuine supply-demand imbalance from slow grinding consolidation that creates false support/resistance clutter.
Break of Structure (BOS)Candle body closes decisively above the prior confirmed swing high after leaving the origin.Candle body closes decisively below the prior confirmed swing low after leaving the origin.Confirms directional intent; highlighting an opposing candle without a structural break produces unvalidated noise boxes.
Fair Value Gap (FVG)Three-candle imbalance where Candle 3 Low sits above Candle 1 High right above the OB.Three-candle imbalance where Candle 3 High sits below Candle 1 Low right below the OB.Indicates rapid order-book repricing where resting limit orders near the origin may not yet have been filled.
Fresh vs. Mitigated StatusPrice has not yet returned into the zone since the BOS printed (first unmitigated touch).Zone remains untouched after bearish displacement; repeated retests weaken statistical reaction.A genuine non-repainting indicator freezes or dims mitigated boxes historically instead of deleting failed boxes cleanly.
Session & HTF AlignmentFormed during active London/NY liquidity and aligned with H4/D1 structural direction.Formed during high-volume institutional windows rather than thin rollover hours.Filters out wide-spread midnight artifacts and lowers counter-trend whipsaw frequency.

Checking Fair Value Gap (FVG) Math in MQL5

When verifying whether an MT5 indicator enforces genuine displacement, inspect how it checks three consecutive bars in series order ([i+2] oldest, [i+1] impulse body, [i] closed confirmation): a valid bullish FVG requires Low[i] > High[i+2] paired with candle [i+1] exceeding a minimum ATR(14) body threshold. Requiring both a Break of Structure and an adjacent FVG eliminates most choppy sideways false zones.

3. Why Free MT5 Order Block Indicators Repaint & How to Verify Visually

Scrolling backward on a static MT5 chart makes almost any Smart Money script look uncannily accurate—because the chart shows only surviving boxes after market structure settled. In live execution, free .ex5 indicators routinely repaint through three distinct mechanisms:

1. Future Swing / Fractal Lookahead Loops

To find a swing high or swing low, an indicator compares bar i against N bars to its left and N bars to its right (for example, a 5-bar fractal). In MT5's default chronological indexing, checking high[i + 1] through high[i + 5] peeks five candles into the future! If the script plots the order block at bar i without explicitly waiting for confirmation bar i + 5 to close, historical charts display crisp entries five bars earlier than was ever possible in real time.

2. Unconfirmed Higher-Timeframe (MTF) Candles

Multi-timeframe order block indicators often draw H4 or D1 zones onto an M15 execution chart. If the script reads the active forming H4 bar (shift 0) rather than waiting for H4 candle close (shift 1), all sixteen M15 sub-candles inside that four-hour window shift or erase their boxes mid-session whenever a sudden wick invalidates the H4 impulse.

3. Silent Deletion of Violated Chart Objects

Many MT5 order block indicators avoid plot buffers entirely and instead paint rectangles via ObjectCreate(OBJ_RECTANGLE). When price slices straight through a weak order block, poorly coded tools call ObjectDelete() to scrub the losing zone off your history. Only zones that happened to bounce stay visible—creating massive survivorship bias during visual inspection.

Step-by-Step: Auditing Any Order Block Indicator in MT5 Strategy Tester Visual Mode

  1. Open MetaTrader 5 and launch the Strategy Tester (Ctrl+R).
  2. Select any blank or baseline Expert Advisor, set Modeling to Every tick or 1 minute OHLC, and check Visualization (Visual mode).
  3. Start the test, pause playback immediately, drag your order block indicator MT5 binary onto the visual chart, and set playback speed low enough to watch bars close one by one.
  4. Write down the timestamp and High/Low price bounds of five new order block rectangles the moment they first appear, plus the exact bar timestamp when they appeared.
  5. Advance 60 to 120 candles and verify two things: (a) existing unmitigated boxes did not jump backward to a different candle, and (b) boxes pierced by price either stayed frozen at their close point or cleanly changed color into a mitigated state rather than disappearing completely.

For deeper buffer-auditing techniques across oscillators and MTF overlays, review our MT4 & MT5 Indicators Guide and Forex Backtesting Guide.

4. Safe Installation in MetaTrader 5 & Reading Buffers with CopyBuffer

Because MetaTrader 5 enforces isolated user data directories per broker terminal hash, copying files into Windows Program Files will not populate your Navigator panel. Follow this clean installation and automation workflow:

  1. 1. Copy into MQL5\Indicators\: Open MT5 and click File → Open Data Folder. Paste your .mq5 source or .ex5 compiled binary inside MQL5\Indicators\ (and any supporting .mqh header files into MQL5\Include\).
  2. 2. Prefer .mq5 Source & Compile in MetaEditor: Whenever .mq5 source code is provided, open it in MetaEditor (F4), inspect OnCalculate() for future-bar index leaks or excessive chart-object creation, and press Compile (F7) to generate a clean .ex5 binary with zero compiler errors.
  3. 3. Keep “Allow DLL imports” Unchecked: An order block indicator calculates strictly from OHLC price arrays and MetaTrader graphical primitives. Leave Allow DLL imports disabled under the Dependencies tab unless you have audited why native Windows calls exist.
  4. 4. Verify Data Window Buffers Before EA Integration: Attach the indicator to a demo chart and press Ctrl+D to open the Data Window. If the Data Window lists numeric Upper/Lower zone prices as you hover across bars, an Expert Advisor can read those values reliably via iCustom() and CopyBuffer(). If the Data Window remains empty, the indicator draws only graphical rectangle objects—meaning an EA would have to scan ObjectsTotal() or implement the candle rules natively in MQL5.
MQL5 Closed-Bar Order Block Buffer Read (CopyBuffer)MQL5 Reference
//+------------------------------------------------------------------+
//| Educational MQL5 Order Block Buffer Read (Closed Bar Safe Pattern)|
//+------------------------------------------------------------------+
int obHandle = INVALID_HANDLE;

int OnInit()
{
   // Replace "CustomOrderBlockMT5" and inputs with exact indicator parameters
   obHandle = iCustom(_Symbol, _Period, "CustomOrderBlockMT5", 10, 1.5);
   if(obHandle == INVALID_HANDLE)
      return(INIT_FAILED);
   return(INIT_SUCCEEDED);
}

void OnTick()
{
   static datetime lastClosedBar = 0;
   datetime currentBarTime = iTime(_Symbol, _Period, 0);
   if(currentBarTime == lastClosedBar)
      return; // Evaluate strictly once per newly completed candle
   lastClosedBar = currentBarTime;

   double bullUpper[], bullLower[];
   ArraySetAsSeries(bullUpper, true);
   ArraySetAsSeries(bullLower, true);

   // Read Data Window (Ctrl+D) buffer indices on closed shift [1]
   if(CopyBuffer(obHandle, 0, 0, 3, bullUpper) < 3) return;
   if(CopyBuffer(obHandle, 1, 0, 3, bullLower) < 3) return;

   if(bullUpper[1] != EMPTY_VALUE && bullLower[1] != EMPTY_VALUE && bullUpper[1] > bullLower[1])
   {
      // Zone active on completed bar [1]: validate spread, BOS, and position sizing
   }
}

void OnDeinit(const int reason)
{
   if(obHandle != INVALID_HANDLE)
      IndicatorRelease(obHandle);
}

5. Risk Management Around Order Block Zones

Because order block candles vary dramatically in height—an H1 EUR/USD origin candle during London open might span 28 pips while an Asian-session M15 candle spans 7 pips—trading fixed lot sizes around order blocks guarantees inconsistent account risk. Follow three quantitative risk rules whenever trading or automating order block zones:

1. Structural Stop Placement + Spread Buffer

Set invalidation stops slightly beyond the distal boundary of the order block (below the bullish OB wick low or above the bearish OB wick high) plus a volatility and spread buffer (for example, 0.20 × ATR plus Ask-Bid spread). On bearish setups, remember MetaTrader stop-losses trigger on the Ask price, not the Bid candles plotted on screen.

2. Dynamic Lot Sizing per Zone Width

Measure exact entry-to-stop distance in pips before entry and convert it into normalized lots using our Lot Size Calculator and Pip Value Calculator. A wider 30-pip H1 order block simply receives one-third the lot volume of a 10-pip M15 zone—keeping dollar risk strictly constant.

Finally, guard against stacked correlated exposure: entering bullish order block retests simultaneously on EUR/USD, GBP/USD, and AUD/USD concentrates triple risk onto a single US Dollar move. Track aggregate account exposure and recovery bounds carefully using the principles in our Drawdown in Forex Trading Guide alongside the repaint-auditing rules in our MT4 & MT5 Indicators Guide.

6. Frequently Asked Questions About MT5 Order Block Indicators

How do you identify a valid order block in MetaTrader 5?
A bullish order block is typically defined as the last bearish candle immediately preceding an impulsive bullish move that breaks a prior swing high (Break of Structure) and leaves a Fair Value Gap imbalance. A bearish order block is the last bullish candle before an impulsive bearish break below a prior swing low.
Do MT5 order block indicators repaint?
Many free order block indicators for MT5 do repaint. Common causes include future-bar swing/fractal lookahead loops that wait N candles to confirm a high or low, projecting incomplete higher-timeframe (MTF) candles onto lower charts, or silently deleting historical rectangle objects once price closes through the zone instead of marking them invalidated.
How can I test if an MT5 order block indicator repaints?
Open the MT5 Strategy Tester (Ctrl+R), enable Visual mode on an M1 or M5 chart using an empty baseline EA, attach the indicator, and slow playback speed. Record exact box coordinates and timestamps when they first appear, advance 50 to 100 candles, and verify whether past boxes shifted, vanished, or appeared retroactively several bars earlier.
Where do I install an order block indicator file in MetaTrader 5?
Open MetaTrader 5 and click File -> Open Data Folder, then copy .mq5 or .ex5 indicator files into MQL5\Indicators\. If you use .mq5 source code, open MetaEditor (F4) and press Compile (F7) to check for zero errors, then right-click Indicators in Navigator (Ctrl+N) and choose Refresh.
Can an MT5 Expert Advisor read order block levels automatically?
Only if the indicator exposes active upper and lower zone prices through numeric INDICATOR_DATA plot buffers (readable via iCustom() and CopyBuffer()) or publishes consistent chart rectangle objects (OBJ_RECTANGLE) with predictable names. Indicators that erase closed boxes or lack buffers are hard to automate reliably.
Where should stop-losses sit when trading order block zones?
Place invalidation stop-losses safely beyond the distal edge of the order block (below the bullish OB low or above the bearish OB high) plus a realistic spread and ATR volatility buffer. Always adjust lot size dynamically based on the resulting pip distance rather than forcing an arbitrary tight stop onto a wide candle.

Trading Risk Notice: Trading leveraged Forex and CFDs carries a high level of risk and may not be suitable for all investors. All guides, calculators, Expert Advisors, and market tools are provided strictly for educational purposes and do not constitute financial advice.

Independence Notice: FXAlgoLab (hosted at forexfactory.cc) is an independent algorithmic trading education resource and is not affiliated with, endorsed by, or connected to Forex Factory or Fair Economy, Inc. (forexfactory.com).

Continue Your Research