Loading…

Stop Level Sampler

MODE_STOPLEVEL is often treated as a fixed property of a symbol, read once and trusted from then on. Some brokers instead widen it dynamically - around news releases, at rollover, or whenever volatility rises - and a strategy that validated its stop distance against a single reading at startup can start having stops rejected hours later with no code change on its side. The only way to see this behaviour is to watch the value over time, which a one-shot read can never do. This script samples MODE_STOPLEVEL and MODE_FREEZELEVEL, together with the current spread, at a fixed interval for a chosen total duration, entirely within one run. A Script has no OnTimer of its own, so the sampling loop runs synchronously, sleeping between samples and checking whether the user has stopped it after every single sample - the samples already collected are still reported even if the run is interrupted early. At the end it reports the minimum, maximum and number of distinct values seen, and states plainly whether the stop level was static or dynamic across the sampling window. Notes and limitations - The script blocks the calling thread for the entire sampling duration, which is expected for a Script and matches how this catalogue's other time-window sampling tools behave; check IsStopped() responsiveness is what lets you cancel it early from the terminal without losing partial results. - Sampling only observes changes that happen to occur between samples that actually ran; a widen-then-revert that both happen inside one interval is invisible to this script, the same limitation any polling-based observer has. - Reports stop and freeze level in points, since that is the unit MarketInfo itself reports them in - convert to pips yourself if your broker quotes in 3 or 5 digits and pips is the unit you think in. - This script only reads market information; it never opens, closes or modifies a trade.

Script · MT5 · v1.0 · Free

About Stop Level Sampler

Stop Level Sampler is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Symbol, Duration minutes and Interval seconds. MQL source code included.

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

Settings

SettingDefaultWhat it does
SymbolSymbol to sample ("" = this chart's symbol)
Duration minutes15Total sampling duration, minutes
Interval seconds15Pause between samples, seconds
Write report filetrueWrite every sample to a CSV

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

MQL4 & MQL5 scripts · PolyMaria