Loading…

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 · MT5 · v1.0 · Free

About Shift Handover Automator

Shift Handover Automator is an expert advisor (trading robot) for MetaTrader 5. It can size trades from your balance and risk percent. It has 7 settings, such as Handover hour, Handover minute and Flatten on handover. MQL source code included.

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

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Handover hour17Hour of day (server time) the shift ends
Handover minute0Minute of that hour
Flatten on handoverfalseClose all matching positions at handover
Magic filter00 = all positions regardless of magic, else only this magic
All symbolstruetrue = consider every symbol, false = only this chart's symbol
Report file prefixShiftHandoverFilename prefix under MQL5\Files
Alert on handovertruePop an Alert() when a handover report is written

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 → Experts.
  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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Trading Sessions · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria