Loading…

Dual Side Bar Recorder

Every Open[]/High[]/Low[]/Close[] array and iOpen/iHigh/iLow/iClose call in MQL4 is bid-side only. A buy order fills on ask, not bid, so any study of a buy-side level - did price actually reach a buy-stop trigger, a buy-limit fill price - computed purely from bid bars is subtly wrong whenever the spread is not a fixed constant. It widens around news, thins in quiet hours, and differs completely between an ECN feed and a fixed-spread retail feed. Reconstructing an ask bar from a bid bar plus an assumed average spread afterwards cannot recover this; the true ask-side high and low can only be known by watching the ask price tick by tick while the bar is still forming. This EA does exactly that: on every tick it folds the current Ask price (already bid+spread, read straight off the live quote) into the ask-side bar for whichever period bucket the chart's own timeframe is currently in. When the chart's native bar closes, the just-completed ask bar and the just-completed native bid bar are written out together as one CSV row, so downstream analysis has bid open/high/low/close and ask open/high/low/close for the identical time window side by side. Notes and limitations Bars are recorded on the chart's own timeframe only - attach one instance per timeframe you want covered. The ask bar for the very first bucket this EA observes is intentionally discarded rather than written with a possibly-wrong open, since ticks before attachment were never seen. A tick gap (thin liquidity, a brief feed interruption) simply means fewer ticks folded into that bucket's ask OHLC, reflected honestly in the AskTickCount column - it does not fabricate missing ticks. This EA never trades. It only reads price data and writes to file.

Expert advisor · MT5 · v1.0 · Free

About Dual Side Bar Recorder

Dual Side Bar Recorder is a script for MetaTrader 5. It has 1 setting, such as Log file. MQL source code included.

Files in the download: DualSideBarRecorder.ex5, DualSideBarRecorder.mq5, DualSideBarRecorder.txt.

Settings

SettingDefaultWhat it does
Log fileDualSideBarRecorder.csvFile written under MQL5\Files\

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 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: News Trading · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria