Loading…

Performance Regression Tracker

Comparing this run's timing against yesterday's single number is nearly useless in practice: normal run-to-run jitter (a busier machine, disk cache state, a wider spread on a benchmark that touches MarketInfo) is often bigger than the change actually being measured. A one-off 8% slowdown can be pure noise, or it can be a real regression - a plain percentage threshold cannot tell the difference. This header instead builds a mean and sample standard deviation from a run of BASELINE samples for a named benchmark, and only flags the NEWEST sample as a regression when it clears mean + k*stdev - a tunable statistical threshold rather than a gut-feel percentage. PerfRegressionCheckLatest() does this in one call: it excludes the newest sample from its own baseline (so a slow run cannot inflate the band that is supposed to catch it), and returns INSUFFICIENT_HISTORY honestly when fewer than two baseline points exist yet rather than guessing. Samples persist across runs. PerfRegressionSaveAllToFile() writes every in-memory sample to a CSV file in the MQL4\Files sandbox; PerfRegressionLoadAllFromFile() reads it back and appends to whatever is already in memory. This is what makes the header useful ACROSS versions of an EA, not just within one Strategy Tester session - run the demo today, run it again next week after changing something, and the noise band is built from real accumulated history rather than resetting to nothing every time. The demo makes the regression flag concrete: it times a small CPU- bound loop several times per run, and by default deliberately makes the LAST sample of each run several times slower, so the regression check has something real to catch on the very first run rather than requiring several days of manual reruns to build history first. Notes and limitations - The noise band needs at least 2 baseline samples (before the newest one) to compute a standard deviation at all; fewer than that returns PERF_VERDICT_INSUFFICIENT_HISTORY rather than a false OK or a false regression. - "Regression" here only ever means "higher than the noise band" - the metric is assumed to be lower-is-better (milliseconds, ticks). A metric where higher is better needs the comparison inverted by the caller. - The in-memory registry is capped at 500 samples total across all labels (PERFREG_MAX_SAMPLES). PerfRegressionSaveAllToFile() overwrites the target file rather than appending to it on disk - load first, record new samples, then save the combined set back. - File I/O is sandboxed to MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) as usual; the CSV is plain text and can be opened directly for inspection.

Script · MT4 · v1.0 · Free

About Performance Regression Tracker

Performance Regression Tracker is a script for MetaTrader 4. It has 4 settings, such as Iterations per sample, Sample count and K stdev multiplier. MQL source code included.

Files in the download: PerformanceRegressionTracker.mqh, PerformanceRegressionTracker.txt, PerformanceRegressionTrackerDemo.mq4.

Settings

SettingDefaultWhat it does
Iterations per sample300000Loop iterations per timed sample - raise if samples read as 0 ms on a fast machine
Sample count5How many timed samples to take THIS run
K stdev multiplier2.0Noise-band width: mean + this many standard deviations
Simulate regression on last sampletrueMake the last sample of this run deliberately slower, to prove detection works

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: MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria