Loading…

Live Excursion Recorder

Reconstructing MFE/MAE from bar history after the fact only sees each bar's high and low, not the actual intra-bar path a trade lived through. A trade that spiked deep underwater and recovered within a single bar looks, in hindsight, identical to one that never went underwater at all - the bar's shadow does not say when during that bar the extreme happened or which of the trader's open positions it applied to. The only way to see that spike is to watch it while the trade is still open. This EA collects every open order in scope on every tick, using a collect-tickets-then-track pattern so the order pool re-indexing during a close never causes a trade to be missed. For each tracked trade it maintains the best and worst price distance from entry seen so far (MFE/MAE in price terms) and the best and worst floating profit seen so far (MFE/MAE in account currency), plus cumulative seconds spent with negative floating profit. The moment a tracked ticket leaves the open pool, its final row - including the closing price/time pulled from order history - is written to the log and the ticket is dropped from tracking. Notes and limitations Tracking is capped at 500 simultaneously open trades (MAX_TRACKED in the source); raise it and recompile if that is ever not enough. A trade that was open before this EA was attached is picked up and tracked starting from that first tick seen - its MFE/MAE will not include any excursion that happened before attachment. A partial close in MQL4 moves the remaining volume to a brand-new ticket rather than keeping it under the original one. When the original ticket disappears from the open pool because of a partial close, this EA looks it up in history; if the history record is not yet available it logs that plainly and discards the row rather than fabricating figures. The remainder trades under its new ticket and is picked up and tracked as a separate row from that point. This EA never trades and never modifies an order - it only reads order state and writes to file.

Expert advisor · MT5 · v1.0 · Free

About Live Excursion Recorder

Live Excursion Recorder is a script for MetaTrader 5. It has 3 settings, such as Magic filter, This symbol only and Log file. MQL source code included.

Files in the download: LiveExcursionRecorder.ex5, LiveExcursionRecorder.mq5, LiveExcursionRecorder.txt.

Settings

SettingDefaultWhat it does
Magic filter00 = track every position on this symbol regardless of magic; otherwise only this magic
This symbol onlytruetrue = only positions on the chart's own symbol; false = every symbol
Log fileLiveExcursionRecorder.csvFile written under MQL5\Files\

How to install

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

Expert advisors (EA) for MT4 & MT5 · PolyMaria