Loading…

Bar Construction Recorder

Most traders only ever notice a bad bar by eye, long after the ticks that would explain it are gone. This EA keeps a running record of the comparison instead: on every tick it updates a locally tracked Open/High/Low/Close for the bar currently forming, and the instant a new bar starts, it compares the just-finished tick-built bar against the terminal's own reported bar for that same time slot (via iOpen/iHigh/iLow/iClose at the matching shift). A mismatch beyond the declared tolerance usually means one of two things: this terminal's tick feed missed ticks that the price feed actually had (a local gap), or the broker revised history after the fact (a server-side rebuild that changed the published bar after this EA had already tracked its own version). Either cause is worth a durable, timestamped record rather than a one-off visual impression. Every finished bar is logged - not only mismatches - so the CSV builds a continuous consistency record across the whole session, with the tick count behind each bar alongside both versions of its Open/High/Low/Close. Notes and limitations The tick-built Open is whatever price this instance of the terminal first observed for that bar - if this EA is attached mid-session, the very first bar it tracks may show a tick-built Open that starts later than the terminal's own bar Open, which was already forming before attach. This does not affect the High/Low/Close comparison used for the verdict. Comparison uses Bid only, matching MQL4's own bar-construction convention on most symbols; it does not separately track an Ask-based bar. A MISMATCH is evidence of a discrepancy, not a diagnosis - it does not distinguish a local tick gap from a broker-side history revision. Cross-check the terminal's own history against another data source when investigating a flagged bar. This EA never trades and never modifies an order - it only reads price data.

Expert advisor · MT4 · v1.0 · Free

About Bar Construction Recorder

Bar Construction Recorder is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Tolerance points, Log file name and Alert on mismatch. MQL source code included.

Files in the download: BarConstructionRecorder.ex4, BarConstructionRecorder.mq4, BarConstructionRecorder.txt.

Settings

SettingDefaultWhat it does
Tolerance points2Allowed High/Low/Close mismatch, in points, before flagging MISMATCH
Log file nameBarConstructionRecorder.csvFile written under MQL4\Files\
Alert on mismatchtrueTurn this alert on or off

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria