Loading…

Chart Event Recorder Player

Interaction testing and macro playback both need the same underlying capability: capture what OnChartEvent() actually received, and be able to play it back later. This library provides a ring-buffer recorder (ChartEventRecorderCapture, called from the top of your own OnChartEvent handler), CSV save/reload so a recording survives a terminal restart, and a player. The honest limit is stated up front rather than glossed over: MQL4 has no API to synthesize a real mouse click, drag or keypress - those only ever originate from the terminal's own input handling, and no CodeBase-legal MQL4 code (no DLL imports) can inject them. What this library CAN genuinely do is redeliver a CUSTOM event (CHARTEVENT_CUSTOM..CHARTEVENT_CUSTOM_LAST) via the real, documented EventChartCustom() call - any EA or indicator with its own OnChartEvent handler receives it exactly as if it had just happened, with the recorded lparam/dparam/sparam intact and the recorded gaps between events replayed (scaled by a speed multiplier). Recorded STANDARD events (clicks, drags, object events, keypresses) are kept in the recording and can be inspected, exported and reasoned about, but the player reports their count rather than re-injecting them, because pretending to fire them would misrepresent what actually happened on screen. The practical use case this shape targets is macro playback for button-driven trading panels: structure the panel's own actions as custom events from the start (a "click Start" button fires CHARTEVENT_CUSTOM+1 rather than being read purely from the raw click coordinates), and this library gives you faithful, timed replay of an entire recorded session for regression testing a panel's logic without a human re-clicking through it by hand. Notes and limitations - Standard chart events (click, drag, object create/delete, keypress) cannot be synthesized by any MQL4 API without a DLL import, which house style forbids. This library records them faithfully for inspection but never re-injects them during playback - only genuine CUSTOM events are redelivered. - The ring buffer drops the OLDEST event once it fills, so a very long recording session silently becomes "most recent N events" rather than growing without bound or crashing. - Timing is captured with GetTickCount() (millisecond resolution, wraps roughly every 49.7 days of terminal uptime - not a concern for a single recording/playback session, but not suitable as an absolute timestamp across a multi-week gap). - A Script has no OnChartEvent() at all in MQL4, so the bundled demo fabricates its own event stream by calling ChartEventRecorderCapture() directly rather than receiving real chart events - exactly what an EA or indicator would do from inside its own handler, just without a Script wrapper capable of receiving events itself. - Replaying custom events only reaches OTHER programs on the SAME chart that have their own OnChartEvent handler attached - it cannot reach a different chart window or a program that has not registered a handler.

Script · MT5 · v1.0 · Free

About Chart Event Recorder Player

Chart Event Recorder Player is a script for MetaTrader 5. It has 1 setting, such as Replay speed. MQL source code included.

Files in the download: ChartEventRecorderPlayer.mq5.mqh, ChartEventRecorderPlayer.txt, ChartEventRecorderPlayerDemo.ex5, ChartEventRecorderPlayerDemo.mq5.

Settings

SettingDefaultWhat it does
Replay speed4.0Replay speed multiplier (higher = faster, shorter waits)

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: MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria