Loading…

Per Signal Cost Threshold Overlay

A signal that "worked" by two pips after costs is a losing trade, not a win - but most crossover indicators never show the actual cost bar a signal has to clear. This overlay marks each Close-vs-SMA cross with an arrow and a "need X.X pips" label computed from the account's real trading costs: the live spread, read every tick via MarketInfo(MODE_SPREAD), plus a user-supplied per-lot commission figure converted into an equivalent price distance using MarketInfo(MODE_TICKVALUE) and MarketInfo(MODE_TICKSIZE) - so a 5-digit forex pair, a JPY cross and a metal all convert correctly through one formula with no hardcoded contract size anywhere. Commission itself has no honest answer: MQL4's MarketInfo() has no commission mode at all, unlike spread, so it genuinely cannot be read live from the terminal and is a required input instead - stated plainly rather than pretending it can be discovered programmatically. What the tool gets right without guessing is the conversion math, which is where a hardcoded contract-size assumption would otherwise quietly break on anything but a standard 100,000-unit forex lot. The displayed cost also uses today's live spread applied uniformly to every signal shown, including older ones on the chart, because MT4 keeps no historical spread record to look up instead - again stated directly rather than implied to be a historically accurate reconstruction. Notes and limitations - Non-repainting: arrows and labels are placed on confirmed crosses using completed bar values. - Commission cannot be read from the terminal in MQL4 and must be entered manually; an incorrect InpCommissionPerLot produces an incorrect cost threshold. - The spread used is always today's live spread, applied to every signal on the chart regardless of when it fired - not a historically accurate per-bar spread, which MT4 does not retain. - This shows the cost floor a move must clear, not a trading recommendation - it does not judge whether a given signal is otherwise a good idea.

Indicator · MT4 · v1.0 · Free

About Per Signal Cost Threshold Overlay

Per Signal Cost Threshold Overlay is an indicator for MetaTrader 4 based on Moving Average. It draws buy and sell arrows on the chart. It has 4 settings, such as Ma period, Commission per lot and Commission is round trip. MQL source code included.

Files in the download: PerSignalCostThreshold.mq4, PerSignalCostThreshold.txt.

Settings

SettingDefaultWhat it does
Ma period20SMA period the base rule crosses against
Commission per lot7.0Round-trip commission per lot, in account currency (broker-quoted, not readable via MarketInfo)
Commission is round triptrueTrue if InpCommissionPerLot already covers open+close, false if it is per side
Label colorclrDarkSlateGrayText label colour

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 → Indicators.
  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 indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Moving Average · Buy/Sell Arrows · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria