Loading…

Overnight Rollover Exposure

Overnight swap - the cost of holding a position across a market close - can be profitable or ruinous depending on the currency pair and the direction held. Many traders carry positions for the swap income, and many more are surprised by how much swap they are paying. The MetaTrader terminal shows swap per position in the Trades tab, but seeing one number on one trade does not tell you the portfolio picture. A trader with five open positions paying swap may not have checked how much total swap is going out of the account each night, or realised that one position is paying out so much swap that it overwhelms the edge on the others. This script walks every open position, reads the swap charge applied to that position by the broker, sums them, and reports the total. It also flags any single position that is carrying an unusually large swap cost, so decisions about closing uneconomical carries can be made immediately. Notes and limitations - Swap shown is the accumulated charge on each position to date, not necessarily tonight's exact charge. Some brokers apply triple swap on Friday, some on Wednesday and Saturday. The exact schedule depends on the broker and symbol. - The annualised figure (swap x 250) is a very rough estimate assuming the position is held for a full trading year. Actual yearly cost depends on when the position is closed. - Pending orders carry no swap and are ignored on both platforms. - On a netting account, only one position per symbol can exist, and its swap figure already reflects everything charged against that symbol. On a hedging account, long and short can both be open, and each may have a different swap cost, reported separately. - This script does not modify positions or swap on either platform. It reports only. - Money handling was checked explicitly for this project: POSITION_SWAP (MQL5) and OrderSwap() (MQL4) both already return money in the account's deposit currency, so there is no tick-value, tick-size or contract-size conversion anywhere in this script, and none was needed.

Script · MT5 · v1.0 · Free

About Overnight Rollover Exposure

Overnight Rollover Exposure is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. MQL source code included.

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

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