Loading…

Snapshot Compare Overlay

Comparing "how today is shaping up" against a specific earlier session (the same day last week, the open before a big news release, a session worth remembering) usually means flipping a chart back in time and trying to hold that shape in memory while looking at today. This script keeps both in front of you at once instead. Save mode writes the last N closed bars' OHLC to a documented CSV file, along with the symbol, period and an optional free-text label so old snapshots stay identifiable. Overlay mode reads that file back and draws it on the live chart as a connected line built from the saved closes - MQL4 has no native polyline object, so the line is built from one OBJ_TREND segment per consecutive pair of points, all sharing one object-name prefix so re-running the overlay replaces the previous one cleanly instead of stacking duplicates. Two adjustments make the comparison meaningful rather than literal: InpTimeShiftSeconds moves the saved times so an old session lines up under today's session instead of sitting on its own original calendar date, and InpAlignPriceToCurrent offsets the saved prices so the snapshot's first point starts at today's current Bid - letting two sessions at completely different price levels be compared by shape rather than by coincidence of matching absolute price. Notes and limitations - The overlay draws closing prices only, as a single connected line - it is a shape comparison, not a full replayed candle-by-candle overlay. - Save mode overwrites InpSnapshotFile in full each run; keep separate filenames for snapshots you want to keep side by side. - If a saved snapshot's own timeframe differs from the live chart's current timeframe, the drawn shape still plots correctly by absolute time and price, but the bar spacing will visually differ from the live chart's own bars - this is expected, not a bug. - Read-only with respect to trading: this script never opens, closes or modifies an order.

Script · MT5 · v1.0 · Free

About Snapshot Compare Overlay

Snapshot Compare Overlay is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Mode, Snapshot file and Bars to save. MQL source code included.

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

Settings

SettingDefaultWhat it does
ModeSNAPSHOT_SAVESave a new snapshot, or overlay a saved one
Snapshot filePriceSnapshot.csvSnapshot file, relative to MQL5\Files
Bars to save200Save mode: how many recent closed bars to store
Snapshot labelSave mode: optional free-text label stored in the header
Time shift seconds0Overlay mode: shift the saved times by this many seconds
Align price to currenttrueOverlay mode: offset saved prices so their first point meets the current Bid
Line colorclrOrangeOverlay mode: colour of the drawn snapshot
Object prefixSnapOverlay_Overlay mode: prefix for the objects this creates

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: Price Action · Trading Sessions · News Trading · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria