Loading…

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

SettingDefaultWhat it does
Line object nameCostMeasure_LineName of the draggable measuring line
Lot size0.10Lot size used to convert the move into money
Stop loss pips20.0Risk unit (pips) the R multiple is measured against
Commission per lot round turn0.0Account-currency commission per lot, round turn (broker statement figure)
Timeout seconds180Give up waiting for the Measure click after this long

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: Scalping · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria