Loading…

Weekend Gap Risk Estimator

A stop loss does nothing while the market is closed. Whatever gap Monday's open prints relative to Friday's close is what a position pays, regardless of where its stop was set, and there is no way to react to it until the market reopens. Most traders carry weekend risk without ever having looked at what their specific symbols have actually done on past Mondays. This script reads the daily bar series for each symbol you currently hold (or a symbol list you supply), finds every Monday bar over a chosen number of weeks, and measures the gap against the prior close in pips. It reports the average gap, the average absolute gap, and the single worst gap seen, then converts each into money using the position's actual lot size and the symbol's tick value and tick size - never a hardcoded contract size, which would be wrong on gold, indices and anything that is not a standard forex lot. The book total adds every symbol's own worst historical gap together as a stress figure, not a probability. Different symbols do not reliably gap in the same direction on the same Monday, so a book total built this way answers "how bad could this plausibly get, symbol by symbol" rather than claiming everything moves against you at once - the script says this explicitly rather than let a single alarming-looking number be read as a forecast. Notes and limitations - A symbol with fewer than five daily bars of history, or with no locally downloaded data at all, is reported as skipped rather than estimated. - Money figures are only computed for symbols with an open position; a symbol supplied in InpSymbolList that is currently flat shows its gap statistics with the cost columns marked not applicable. - The book total sums each symbol's own worst historical gap independently. It is a per-symbol stress figure, not a joint probability that every symbol gaps its worst at the same time. - Holidays and broker-specific closures can shift which weekday actually carries the "Monday" bar in the daily series; the script reads whatever day-of-week the terminal's own history assigns to that bar. - Past gaps are historical fact, not a guarantee about the next one - central bank surprises and geopolitical events can produce a gap larger than anything in the sample window.

Script · MT5 · v1.0 · Free

About Weekend Gap Risk Estimator

Weekend Gap Risk Estimator is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Symbol list and Weeks to analyze. MQL source code included.

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

Settings

SettingDefaultWhat it does
Symbol listComma-separated symbols to analyse ("" = every open position's symbol)
Weeks to analyze52How many Monday gaps back to measure

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

MQL4 & MQL5 scripts · PolyMaria