Loading…

Net Position Synthesiser

A symbol carrying a buy of 0.30, a sell of 0.10 and a buy of 0.05 open at the same time is not three positions - it is one net long 0.25 wearing three tickets. Scaling in, partial hedges, and EAs with different magic numbers all accumulate this kind of clutter over time, and the ticket list alone does not show how much of it is real exposure versus offsetting noise. This script computes the net lot size per symbol from every open position, normalised to that symbol's lot step, and reports it next to the number of tickets currently contributing to it. A symbol whose tickets fully cancel out is reported as net flat, needing no trade at all to reproduce; everything else is reported as the single buy or sell that would hold the same net exposure with one ticket instead of many. The script does not act on this. Turning "3 tickets on EURUSD" into "1 ticket on EURUSD" for real means closing the existing tickets and opening a new one, which pays spread and commission again and realises whatever floating P/L sat on the closed side - a decision with real cost that belongs to the trader, made with the report in hand, not something a script should do unattended. Notes and limitations - Read-only: no order is opened, closed or modified. The report exists to inform a manual decision, not to automate one. - Net lots are normalised to each symbol's MODE_LOTSTEP so the reported "synthesised trade" is a lot size that could actually be sent; a net smaller than half the symbol's minimum lot is reported as flat. - The report treats every ticket on a symbol as fungible for netting purposes, regardless of magic number, unless InpMagicFilter restricts the scan to one magic - mixing tickets from different EAs into one net figure may not match how those EAs intend to manage their own positions independently. - Consolidating tickets manually pays spread and commission on the closing and reopening trades, and realises the P/L on whichever side is closed - the reported ticket-count reduction is not free. - Pending orders carry no exposure and are excluded; only open market positions are netted.

Script · MT5 · v1.0 · Free

About Net Position Synthesiser

Net Position Synthesiser is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 1 setting, such as Magic filter. MQL source code included.

Files in the download: NetPositionSynthesiser.ex5, NetPositionSynthesiser.mq5, NetPositionSynthesiser.txt.

Settings

SettingDefaultWhat it does
Magic filter-1Magic number filter for positions considered (-1 = every magic)

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: Hedging · Risk & Lot Size · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria