Loading…

Excursion By Setup Tag

A single win-rate or average-profit figure hides a real difference between setups: two comments in the same history can win at the same rate while one needed a stop three times wider than the other to survive its normal drawdown. This script walks closed order history, groups trades by OrderComment() exactly as written, and for each group reports the average and median favourable excursion (MFE, how far price ran in the trade's favour) and adverse excursion (MAE, how far it ran against it) before the trade closed. MT4 never records intrabar excursion on a closed order - only the open and close price. The only reconstruction available from inside the terminal is the local M1 history for the symbol, walked bar by bar between the trade's open and close time. That reconstruction is only as good as the M1 history actually downloaded: a trade whose window falls outside local M1 coverage is counted as skipped, never silently guessed at, and the skip count is printed so a thin report is never mistaken for a complete one. Grouping is deliberately literal. The script does not try to parse or normalise the comment string - if two setups used slightly different comment text, they are reported as two separate rows. That is a feature, not a gap: any normalisation is a modelling choice the trader is better placed to make than the script. Notes and limitations Requires local M1 history for every symbol being measured; download it in advance (Tools -> History Center) for accurate coverage, especially on older trades. Trades whose stop-loss was moved after entry still have their full open-to-close window measured for excursion - this script measures price movement, not risk actually taken, which is a different question. Comment text recorded by some brokers/EAs can be truncated or altered server-side; this script reports whatever OrderComment() returns as-is.

Script · MT4 · v1.0 · Free

About Excursion By Setup Tag

Excursion By Setup Tag 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 Symbol filter, Magic filter and From date. MQL source code included.

Files in the download: ExcursionBySetupTag.mq4, ExcursionBySetupTag.txt.

Settings

SettingDefaultWhat it does
Symbol filterSymbol filter ("" = every symbol)
Magic filter-1Magic number filter (-1 = every magic)
From date0Earliest close time (0 = all loaded history)
To date0Latest close time (0 = up to now)
Min per tag3Minimum measured trades before a tag is reported
Blank as no tagtrueGroup trades with an empty comment under "(no tag)"

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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 · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria