Best Trades Highlight Export
Scrolling the terminal's Account History tab to find your best trades does not scale past a few dozen tickets, and it gives no sense of scale - a 200 dollar winner and a 2000 dollar winner look the same length on the list. This script ranks every closed trade by R multiple (profit as a multiple of the money actually risked on the stop) and writes the top N, in full detail, to one CSV file. R multiple needs a stop-loss to divide by. MQL4 keeps no modification history for a closed order - OrderStopLoss() only ever returns the last value the order carried, which for a trailed or breakeven-moved trade is the stop that was in place at close, not the one set at entry. The script uses that value as the best available proxy and says so plainly rather than pretending it recovered the true original stop. Trades with no stop on record at all (OrderStopLoss() is zero) are skipped from the ranking and counted separately in the log, rather than silently treated as R multiple zero. Ranking works on real money risk, not points, using each trade's own symbol's point value - so a 50 pip winner on a small-lot trade and a 10 pip winner on a large-lot trade compare on the money that was actually at stake, not on distance alone. Notes and limitations Only market orders (OP_BUY/OP_SELL) that closed are considered - pending orders that were cancelled or expired never opened a position and have no R multiple to compute. The stop-loss used for the risk denominator is the order's last recorded value, not necessarily the value that was in place at entry - see the full description above. Trades with no stop on record are excluded from the ranking entirely, not scored as R multiple zero, and the count of excluded trades is printed to the Experts log. A trade whose symbol's tick value/tick size cannot currently be read from MarketInfo (the symbol is not in Market Watch and the terminal has never loaded its spec) is treated the same as "no stop" and excluded, since risk in money cannot be computed without it. Ranking is a full scan of the account's closed-order history every run; on an account with many thousands of closed trades this can take a few seconds.
Script · MT5 · v1.0 · Free
About Best Trades Highlight Export
Best Trades Highlight Export 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 Top n, Magic filter and Symbol filter. MQL source code included.
Files in the download: BestTradesHighlight.ex5, BestTradesHighlight.mq5, BestTradesHighlight.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Top n | 10 | How many top trades to export |
| Magic filter | -1 | Magic number filter (-1 = every magic) |
| Symbol filter | Symbol filter ("" = every symbol) | |
| File name | BestTradesHighlight.csv | Output file, written into MQL5\Files\ |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 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 · MT5 Script · MQL5 Source Code