Loading…

Trade Marker Annotator

The account history tab tells you what closed and for how much. It does not show you where on the chart it happened relative to the move that was actually playing out - was the entry into strength or a bounce, was the exit early or exactly at the reversal. Reconstructing that by hand means reading open time and price off the history tab and hunting for the matching bar, one trade at a time. This header draws the whole picture directly: a directional arrow at entry, a check-style marker at exit, a dotted line connecting them coloured by outcome, and a profit label near the exit price. AnnotateHistoryTrades walks closed trade history, filters to genuine trades with a real open/close price pair, and draws every trade matching an optional symbol and magic number filter. Every object is named from a per-trade identifier, so annotating the same history twice never produces duplicate overlapping markers, and RemoveAnnotations clears an entire annotated set by its prefix alone. The lower-level DrawTradeMarker primitive is exposed separately for anyone who wants to annotate trades from their own data - a journal, a backtest report - rather than from live history. Notes and limitations - Only genuine market trades are drawn. MQL4: OP_BUY/OP_SELL only, pending order cancellations and balance/credit entries skipped. MQL5: DEAL_TYPE_BUY/SELL exit deals only, balance/credit/other deal types skipped the same way. - MQL5's profit label uses only the exit deal's DEAL_PROFIT+DEAL_SWAP+ DEAL_COMMISSION. If a broker also charges commission on the entry deal separately, that portion is not included and the figure understates true net cost slightly - an honest limitation, not a bug, of reading one deal rather than summing every deal tied to the position id. - MQL5's entry-deal lookup (FindEntryDeal) scans the loaded history linearly per exit deal found - O(n) per trade, fine for a typical account's history size, not designed for accounts with tens of thousands of closed deals in one AnnotateHistoryTrades() call. - Objects are placed at the trade's own open/close time and price, which may fall outside the currently visible chart range for old history - scroll or zoom out if nothing appears. Identical on both platforms. - Re-running AnnotateHistoryTrades with the same prefix does not duplicate markers (identifier-based naming overwrites in place), but call RemoveAnnotations first if you want a completely clean redraw, for example after changing the symbol or magic filter. Identical on both platforms. - Chart objects only - nothing here reads or writes files, and nothing here places, modifies or closes any order or position, on either platform.

Script · MT4 · v1.0 · Free

About Trade Marker Annotator

Trade Marker Annotator is a script for MetaTrader 4. It draws buy and sell arrows on the chart. It has 3 settings, such as Symbol filter, Magic filter and Display sec. MQL source code included.

Files in the download: TradeMarkerAnnotator.mqh, TradeMarkerAnnotator.txt, TradeMarkerAnnotatorDemo.mq4.

Settings

SettingDefaultWhat it does
Symbol filterBlank = annotate every symbol's history
Magic filter-1-1 = every magic number
Display sec12Seconds to leave markers on the chart

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: Buy/Sell Arrows · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria