Draw Trade History On Chart
The Account History tab lists every closed trade as a row of numbers - ticket, open time, open price, close time, close price, profit - and reading it tells you what happened without showing you where. Whether a trade was closed into a clean breakout or chopped out in a range is invisible in a table. Seeing the same trades plotted against the price that produced them is a different, more useful kind of review. This script walks the closed-trade history for the current symbol and draws each qualifying trade as three objects: an up or down arrow at the entry price and time, a stop-sign arrow at the exit, and a dotted line connecting them, all coloured green for a win, red for a loss, and grey for an exact breakeven. A text label at the exit carries the ticket number, direction and money result, so hovering near a cluster of trades identifies each one without opening the history tab at all. The money result is never a raw close-minus-open price difference. It is built from the actual money figures the account was charged and credited for that trade - profit, swap and commission together - so a naive version of this script that only compares prices would colour a trade green even when swap or commission turned a positive price move into a net loss, which is exactly backwards for a tool whose purpose is showing what really happened. History is walked backwards from the newest closed trade, and InpMaxTrades caps how many are drawn. That ordering matters: capping a forward scan from the oldest trade would keep the trades furthest in the past on an account with a long history, when a review is almost always about the recent ones. Walking backwards keeps the most recent trades by construction. Notes and limitations - Only market trades are drawn. Expired or cancelled pending orders never produced a fill and have no meaningful entry price to anchor an arrow on, so they are skipped on both platforms. - Partial closes appear as separate rows on both platforms. On MQL5 specifically, the position's entry commission is attributed only to the row for the final exit deal - see the DIFFERENCES section above for why, and be aware that an individual partial-close row before the final one will show a slightly smaller commission charge than an equivalent full close would have, even though the position-wide total is correct. - The chart must have enough loaded history to show the dates involved; a trade older than what the chart has scrolled back to will still have its objects created, they simply will not be visible until the chart is scrolled to that date. - This is a one-time drawing, not a live-updating overlay. New trades closed after the script runs are not added automatically - run it again to include them.
Script · MT4 · v1.0 · Free
About Draw Trade History On Chart
Draw Trade History On Chart is a script for MetaTrader 4. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 7 settings, such as This symbol only, Lookback days and Max trades. MQL source code included.
Files in the download: DrawTradeHistoryOnChart.ex4, DrawTradeHistoryOnChart.mq4, DrawTradeHistoryOnChart.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| This symbol only | true | Only draw deals on the chart's current symbol |
| Lookback days | 30 | Only draw deals closed within this many days (0 = no limit) |
| Max trades | 200 | Hard cap on how many closed trades are drawn |
| Profit color | clrForestGreen | Line/arrow colour for a winning trade |
| Loss color | clrCrimson | Line/arrow colour for a losing trade |
| Breakeven color | clrGray | Line/arrow colour for a zero-result trade |
| Prefix | trdh_ | Prefix for every object this script draws |
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: Breakout · Buy/Sell Arrows · Alerts · MT4 Script · MQL4 Source Code