Monte Carlo Narrated Demo
"Monte Carlo simulation" is a phrase traders repeat without necessarily having watched one happen. This script runs the smallest version that still teaches the point: take ten trades (typed in, or the account's own last ten closed trades), then resample ten outcomes WITH replacement from that same pool, several times over, printing every draw as it happens - which original trade got picked, and the running balance after it. Because each draw is independent and with replacement, a resample can pick the same trade several times and skip another entirely. That is exactly why the final balance differs from resample to resample even though every draw comes from the identical ten numbers - and that variation is the lesson itself. Ten trades, real or simulated, is a small enough sample that which ones happen to repeat can meaningfully move the outcome; a single ten-trade stretch is one noisy sample, not a settled verdict on a system. The script also tracks the peak balance and worst drawdown reached during each narrated resample, so the point extends beyond the final number to the path taken to get there. Notes and limitations - Account-history mode assumes closed-order history index order approximates chronological order when picking the "last 10" trades - stated here plainly since MT4 gives no other cheap way to identify recency from a plain backward scan. - If fewer than 10 closed trades match the filter, the script falls back to the typed InpTrade1..InpTrade10 values and says so via Alert. - This is a teaching tool about small-sample variability, not a forecasting tool. Ten trades, bootstrapped any number of times, cannot tell you what an 11th trade will do.
Script · MT4 · v1.0 · Free
About Monte Carlo Narrated Demo
Monte Carlo Narrated Demo is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 16 settings, such as Use last ten closed trades, Magic filter and Symbol filter. MQL source code included.
Files in the download: MonteCarloNarratedDemo.mq4, MonteCarloNarratedDemo.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Use last ten closed trades | false | If true, use this account's last 10 closed trades instead of the typed ones below |
| Magic filter | -1 | Account-history mode only: magic filter (-1 = all) |
| Symbol filter | Account-history mode only: symbol filter ("" = all) | |
| Starting balance | 10000.0 | Notional starting balance for the narrated run |
| Trade1 | 62.50 | Manual mode: your trade 1 P/L, account currency (illustrative default - type your own) |
| Trade2 | -40.00 | Manual mode: your trade 2 P/L |
| Trade3 | 85.00 | Manual mode: your trade 3 P/L |
| Trade4 | -55.00 | Manual mode: your trade 4 P/L |
| Trade5 | 30.00 | Manual mode: your trade 5 P/L |
| Trade6 | -70.00 | Manual mode: your trade 6 P/L |
| Trade7 | 95.00 | Manual mode: your trade 7 P/L |
| Trade8 | -25.00 | Manual mode: your trade 8 P/L |
| Trade9 | 45.00 | Manual mode: your trade 9 P/L |
| Trade10 | -35.00 | Manual mode: your trade 10 P/L |
| Number of resamples | 5 | How many bootstrap resamples to narrate |
| Random seed | 0 | Seed for MathSrand (0 = use GetTickCount, different every run) |
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