Cost Adjusted Measure Tool
MetaTrader's own ruler tool reports a raw price distance. It does not know the account's spread or commission, so the number it shows always overstates what a real trade actually captures - sometimes by very little, sometimes, on a short scalp against a wide spread, by most of the move. This script measures the same kind of distance but reports two figures side by side: the raw move, and the same move after subtracting the symbol's live spread and a commission figure supplied by the trader. MQL4 has no function that reads a broker's live commission rate, so InpCommissionPerLotRoundTurn is deliberately a number the trader enters from their own account statement, not a guessed or hardcoded one. Because a Script has no click handler (OnChartEvent does not exist for Scripts), the two points are set by dragging a trend line's own two ends - the script creates one automatically if none exists - and confirmed with an on-chart "Measure" button. The script waits for that click in a bounded polling loop rather than blocking forever, so it always ends even if nobody drags anything. Notes and limitations - The measuring line is left on the chart after the script finishes so the trader can see what was measured; delete it manually, or with the companion "Delete Objects By Prefix" style tool, when finished. - If the timeout expires or the script is removed before the Measure button is clicked, nothing is reported and the line is left as-is. - Adjusted pips and money can be negative when spread and commission exceed the raw move - the report states this plainly rather than clamping it to zero. - Spread is read live at the moment Measure is clicked; it is not a historical or averaged figure.
Script · MT5 · v1.0 · Free
About Cost Adjusted Measure Tool
Cost Adjusted Measure Tool is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Line object name, Lot size and Stop loss pips. MQL source code included.
Files in the download: CostAdjustedMeasure.ex5, CostAdjustedMeasure.mq5, CostAdjustedMeasure.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Line object name | CostMeasure_Line | Name of the draggable measuring line |
| Lot size | 0.10 | Lot size used to convert the move into money |
| Stop loss pips | 20.0 | Risk unit (pips) the R multiple is measured against |
| Commission per lot round turn | 0.0 | Account-currency commission per lot, round turn (broker statement figure) |
| Timeout seconds | 180 | Give up waiting for the Measure click after this long |
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: Scalping · Alerts · MT5 Script · MQL5 Source Code