Shift Handover Automator
Anyone trading in defined shifts - a prop-firm session limit, a hand-off between two people running the same account, or simply a personal "I stop trading at this time" rule - has to do the same manual checklist at the boundary: check what is still open, decide whether to flatten, and write down what happened for whoever (or whatever future self) looks at the account next. Doing this by hand every day is exactly the kind of routine that gets skipped on a busy day. This EA watches server time and, once per calendar day at a configured hour and minute, snapshots every open position matching an optional magic-number and symbol-scope filter, optionally closes them, and writes a CSV report recording the account balance and equity, the open position count and floating P/L before and after, the count and net result of trades closed since the shift began, and how many positions were flattened at handover. Shift boundaries are not just held in memory. The shift start time and the date of the last handover already run today are written to a small state file after every change, so restarting the terminal mid-shift does not lose track of when the current shift began, and does not risk firing a second handover for a time already handled earlier the same day. Notes and limitations The handover fires once per calendar day at the configured time using server time - if the terminal is closed at that exact minute and reopened later the same day, the handover runs the first time the EA is ticking again after that time, not retroactively at the exact minute. Flattening closes market positions only (OP_BUY/OP_SELL); pending orders are left untouched. "Trades closed during shift" is determined by comparing each history order's close time against the recorded shift start - a shift that spans a terminal restart still measures correctly because the shift start itself is persisted, not just tracked in memory. This EA does not manage trades during the shift - it only reads state, optionally closes positions at the boundary, and writes the report.
Expert advisor · MT4 · v1.0 · Free
About Shift Handover Automator
Shift Handover Automator is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Handover hour, Handover minute and Flatten on handover. MQL source code included.
Files in the download: ShiftHandoverAutomator.ex4, ShiftHandoverAutomator.mq4, ShiftHandoverAutomator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Handover hour | 17 | Hour of day (server time) the shift ends |
| Handover minute | 0 | Minute of that hour |
| Flatten on handover | false | Close all matching positions at handover |
| Magic filter | 0 | 0 = all orders regardless of magic, else only this magic |
| All symbols | true | true = consider every symbol, false = only this chart's symbol |
| Report file prefix | ShiftHandover | Filename prefix under MQL4\Files |
| Alert on handover | true | Pop an Alert() when a handover report is written |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 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 · MT4 Expert Advisor · MQL4 Source Code