Overnight Versus Intraday Return Split
A daily close-to-close return is really two different things stacked together: the gap that happens while the session is closed (or thin), and the move that happens while it is actively trading. Equity index and stock traders study this split routinely; this script brings the same decomposition to whatever symbol is on the chart. For every completed daily bar it computes intraday = close - open for that day, and overnight = open - previous day's close, both converted to pips. The two are summed separately across the requested history, along with their mean, standard deviation and the share of days each moved in the favourable (up) direction. The naive version of this gets the accounting wrong somewhere - usually by mismatching which bar's close pairs with which bar's open when a weekend or holiday breaks the daily sequence. This script sidesteps that by reading both bars directly from the D1 series (this day's own open and close, and the immediately PRECEDING D1 bar's close) rather than assuming a fixed number of calendar days between them, and then proves the bookkeeping is correct by printing an identity check: the sum of the two components should equal the plain close-to-close change across the whole window, and the script prints both figures side by side so any mismatch is visible immediately rather than trusted silently. Notes and limitations "Overnight" here means the close-to-open gap as recorded by this symbol's own D1 bars - for a 24-hour market (most forex pairs, crypto CFDs) that gap is small and mostly reflects the daily bar boundary the broker uses, not an actual market closure. The split is most meaningful on instruments with a genuine daily trading halt (indices, single stocks, many futures CFDs). Win rate as reported is simply the share of days each component moved in the positive (up) direction - it says nothing about magnitude, and a component can have a positive win rate while still summing to a net negative total if its losing days are larger on average. This is a historical decomposition, not a trading signal. It reports where a symbol's past move came from; it does not claim the same split will hold going forward.
Script · MT5 · v1.0 · Free
About Overnight Versus Intraday Return Split
Overnight Versus Intraday Return Split 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 Days to study and Save csv. MQL source code included.
Files in the download: OvernightIntradaySplit.ex5, OvernightIntradaySplit.mq5, OvernightIntradaySplit.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Days to study | 500 | Most recent completed trading days to include |
| Save csv | true | Write the per-day decomposition to a CSV file |
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: Trading Sessions · Alerts · MT5 Script · MQL5 Source Code