Slippage Budget Planner
MT4 never stores the price that was actually requested when an order was sent, so slippage cannot be read directly off a closed order the way commission or swap can. This script reconstructs it the way a trader would eyeball it after the fact: each closed market trade's fill price is compared against the M1 bar's open price at its open time, used as a reasonable proxy for "the price when the order was placed". Both adverse and favourable slippage are counted - a broker's fills are rarely one- directional - and converted to money using that trade's own lot size via tick value and tick size, never a hardcoded contract size, so trades of different sizes combine honestly into one money statistic. From the sampled trades the script computes a mean, a standard deviation and a worst single-trade figure, then proposes a per-trade slippage budget as the mean plus a configurable multiple of the standard deviation - a worst-case allowance rather than an average-case one, since sizing decisions should survive an unlucky trade, not just a typical one. When a typed expectancy-per-trade figure is supplied, the script checks whether the slippage budget alone would consume it, and says so plainly rather than leaving the comparison to be done by eye. Notes and limitations - The M1-bar-open proxy is an approximation of the requested price, not the broker's own record of it - no such record exists in MT4. Treat the resulting figures as a reasonable estimate, not an audited one. - Trades whose M1 bar has since aged out of local history are skipped and reported as such, not silently dropped. - The sample only covers market entries (OP_BUY/OP_SELL); pending-order triggers and closes are not measured, since only the open side is being compared against a "requested price" proxy here. - A thin sample (few recent trades) produces a noisy standard deviation; the reported figures are only as reliable as the sample size behind them.
Script · MT4 · v1.0 · Free
About Slippage Budget Planner
Slippage Budget Planner is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Lookback trades, Current symbol only and Confidence multiplier. MQL source code included.
Files in the download: SlippageBudgetPlanner.mq4, SlippageBudgetPlanner.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Lookback trades | 50 | Most recent closed market trades to sample |
| Current symbol only | true | Restrict the sample to this chart's symbol |
| Confidence multiplier | 2.0 | Budget = mean + multiplier * standard deviation |
| Expectancy per trade | 0.0 | Typed expectancy per trade, account currency (0 = skip the warning) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code