Floating Profit Currency Attribution
A book showing five winning tickets and two losing ones does not tell you why you are up or down. It can be almost entirely explained by one currency doing one thing - USD strength that day, say - spread across several symbols that each look like an independent bet from the ticket list. This script applies the same base/quote decomposition this catalogue's currency exposure tools use, but to the floating profit figure instead of the notional. Each position's floating profit (the broker-computed price P/L already in account currency) is credited to its base currency and mirrored as a negative to its quote currency - the identical sign convention exposure decomposition uses, just carrying profit instead of units. Summing that across every open position turns the ticket list into a short per-currency table, and the currency with the largest absolute net is named as the driver. The mirrored sign is a modelling convention, not a claim that the money is duplicated: it lets a currency that appears on the base side of some pairs and the quote side of others net out correctly, so a currency's row genuinely reflects its overall correlation with the book's floating result rather than one pair in isolation. Only standard 6-letter FX pair names are decomposed. Anything else - indices, non-FX CFDs, a symbol name shorter than six characters - is counted in the totals but excluded from the currency table and reported separately, since a base/quote split has no meaning for them. The script only reads. It opens nothing, closes nothing, modifies nothing. Notes and limitations - Attribution is a modelling convention (base currency credited, quote currency mirrored negative), not a physical split of money - the actual profit is realised in account currency on each ticket exactly as MetaTrader reports it. The currency table exists to show correlation across the book, not to reassign real money between currencies. - Swap and commission are excluded; only the price-driven floating P/L (OrderProfit) is attributed. - Symbols shorter than six characters, or whose first three characters equal the next three, are excluded from the currency table and listed as a separate unattributed total. - A single dominant position can make its currency look like "the driver" even when the rest of the book is flat - always cross-check against the position breakdown table before acting on the headline.
Script · MT5 · v1.0 · Free
About Floating Profit Currency Attribution
Floating Profit Currency Attribution is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Magic filter and Show position table. MQL source code included.
Files in the download: FloatingProfitAttribution.ex5, FloatingProfitAttribution.mq5, FloatingProfitAttribution.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Magic filter | -1 | Magic number filter for positions considered (-1 = every magic) |
| Show position table | true | Also print the position-level breakdown |
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: Alerts · MT5 Script · MQL5 Source Code