Loading…

Currency Exposure Report

Long EURUSD, long GBPUSD, short USDJPY and short USDCHF looks like four trades. It is mostly one trade: short the dollar four times. Position lists hide this because they are organised by symbol, and a symbol is a ratio of two currencies, not a thing you are long or short of. This script does the decomposition properly. A long lot of EURUSD becomes two legs: plus one contract of EUR, minus the same notional in USD at the current price. Every open position is split that way, the legs are netted per currency, and each net is valued in your account currency so the sizes are comparable. The result is a short table: which currencies you are actually long and short of, and by how much, largest first. Gold longs show up as a net XAU line - for exposure purposes a metal is just another currency. Two design choices matter more than the arithmetic. Conversion pairs are found by the currencies each symbol declares, never by gluing strings together. A script that builds "EURUSD" by concatenation breaks on every broker that lists EURUSD.m or EURUSD.pro; this one scans the symbol list for a pair whose declared base and profit currencies match, so suffixes are irrelevant. Conversion tries a direct pair, then an inverse pair, then a two-leg route through USD. When something cannot be resolved, the script says so instead of guessing. A currency with no conversion path is shown with its raw amount and the words "conversion failed". A position whose symbol declares no usable currency metadata - some index CFDs declare the same currency on both sides, which would make the legs cancel and the position vanish - is listed under "unclassified" with the reason. Nothing is silently dropped and nothing is silently invented. The script only reads. It opens nothing, closes nothing, modifies nothing. Notes and limitations - The quote leg is sized at the current bid, not the open price, because the report answers "what am I exposed to now". The difference is your floating profit, which is small next to the notional but not zero. - Notional decomposition is exact for spot FX and metals. For index and commodity CFDs it reports what the broker's currency metadata implies; when that metadata is degenerate the position goes to "unclassified" instead. - Conversion uses the current bid of whichever conversion pair is found, so converted values carry the spread of that pair. For a risk overview this is irrelevant; for accounting it is not the right tool. - A conversion pair that exists but has never been quoted in this terminal session can price at zero; the script then reports the conversion as failed rather than valuing the exposure at nothing. - Swap and unrealised profit are not part of the exposure figures. - Needs a broker that fills in currency metadata (any MT4 build 600+ / MT5 server does; very old feeds may not).

Script · MT4 · v1.0 · Free

About Currency Exposure Report

Currency Exposure Report is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Show position table and Save csv. MQL source code included.

Files in the download: CurrencyExposure.ex4, CurrencyExposure.mq4, CurrencyExposure.txt.

Settings

SettingDefaultWhat it does
Show position tabletrueShow the position-level breakdown
Save csvfalseAlso write the report to a CSV file

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 → Scripts.
  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 script onto a chart to run it once.

Download the PDF guide

Tags: EURUSD · GBPUSD · USDJPY · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria