R Multiple Distribution Export
A win rate and a profit factor collapse a trading history into two numbers that can hide the actual shape of the outcomes - a system with a 40% win rate can be healthy or broken depending on whether the losses cluster tightly near -1R or have a long, uncontrolled tail. This script computes each closed trade's R multiple (profit as a multiple of the money risked on its stop) and bins them into a configurable histogram, exported as CSV, so that shape can be plotted or eyeballed directly. Like the companion Best Trades Highlight export, R multiple needs a stop-loss to divide by, and MQL4 keeps no modification history for a closed order - the stop used is whatever OrderStopLoss() last reported, which is the stop in place at close, not necessarily the one set at entry, if the trade was trailed or moved to breakeven. Trades with no stop on record are excluded from the histogram and counted separately, not folded silently into one of the bins. The point-value and R-multiple calculation is written independently in this file rather than shared with Best Trades Highlight Export, since each CodeBase submission must be self-contained and downloadable on its own. Notes and limitations Only market orders (OP_BUY/OP_SELL) that closed are considered. Trades with no stop-loss on record, or on a symbol whose tick value/tick size cannot currently be read from MarketInfo, are excluded from the histogram and reported as a separate skipped count in the Experts log, not scored into a bin. Mean and standard deviation of R across the included trades are printed to the log for context but are not written into the CSV file itself, which holds only the bin table so it can be charted directly without extra columns to ignore. A trade landing exactly on a bin boundary is placed in the higher bin (the boundary belongs to the bin above it), matching the UNDER_MIN/OVER_MAX boundary convention used for InpMinR and InpMaxR themselves.
Script · MT4 · v1.0 · Free
About R Multiple Distribution Export
R Multiple Distribution Export is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 6 settings, such as Bin width r, Min r and Max r. MQL source code included.
Files in the download: RMultipleDistribution.mq4, RMultipleDistribution.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Bin width r | 0.5 | Width of one histogram bin, in R |
| Min r | -3.0 | Lowest bin's lower edge, in R |
| Max r | 5.0 | Highest bin's upper edge, in R |
| Magic filter | -1 | Magic number filter (-1 = every magic) |
| Symbol filter | Symbol filter ("" = every symbol) | |
| File name | RMultipleDistribution.csv | Output file, written into MQL4\Files\ |
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