Loading…

Rollover Cost Attribution

MT4 already keeps price-movement profit (OrderProfit), swap (OrderSwap) and commission as three separate fields on every closed order, but the history tab shows them blended into one net figure. A strategy that looks profitable on net P/L can be losing on price movement alone and only breaking even because of a favourable swap rate - or the reverse, winning on price movement while a punishing swap eats most of it. Net P/L alone cannot tell these apart. This script sums all three fields separately across the account's closed history and reports them side by side, then splits the same totals again by whether each trade's hold crossed at least one weekend. A trade that opened Thursday and closed the following Tuesday reads very differently if most of its swap came from two ordinary weeknights versus one weekend's worth of carry, usually charged as a single triple-sized night - keeping the two buckets separate stops a handful of long weekend holds from quietly dominating the "typical" swap figure for every other trade. Notes and limitations - A trade is classed as weekend-carrying if any calendar day it spanned fell on a Saturday, regardless of exact hold duration - it does not try to compute exactly how many nights of swap were weekend-related versus ordinary. - Pending orders that never filled, and orders still open, are excluded; this report covers realised closed-trade history only. - Commission is included in the account-wide total but not split by weekend crossing, since most brokers charge it flat per trade regardless of hold duration. - This is a historical report, not a projection - it describes what already happened, not what a future hold is likely to cost.

Script · MT5 · v1.0 · Free

About Rollover Cost Attribution

Rollover Cost 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 Symbol filter and Max history to scan. MQL source code included.

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

Settings

SettingDefaultWhat it does
Symbol filter"" = every symbol, otherwise only this one
Max history to scan0Most recent closed deals to scan (0 = every closed deal)

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

MQL4 & MQL5 scripts · PolyMaria