Prop Weekend Deadline Enforcer
Prop firms publish weekend flatten deadlines in a fixed zone - usually UTC, or a US exchange zone converted to UTC in the rulebook. Broker server time is not that zone, and it drifts against UTC through the year as the broker applies its own DST rule on its own dates, which rarely match the trader's own calendar. A deadline hard-coded against broker time silently drifts wrong twice a year, right when it matters most. This EA reads the deadline as a UTC weekday and UTC hour/minute, and converts broker server time to UTC on every check using TimeGMTOffset() - a live broker-reported offset that already accounts for the broker's own DST state, not a value the trader has to track by hand. A warning alert fires a configurable number of minutes before the deadline, and the actual flatten - closing open positions and, optionally, deleting pending orders - fires a second, shorter countdown before it. Both actions are latched to the UTC calendar week they belong to, so a terminal restart minutes after the deadline cannot re-trigger a flatten that already happened, and a restart earlier in the week still catches the deadline correctly. Both a magic-number filter (to flatten only one strategy's orders while leaving the rest alone) and an "all magic numbers" mode (0) are supported, since some traders run this as a whole-account safety net and others run one instance per strategy. Notes and limitations TimeGMTOffset() reports the broker's own current GMT offset as the terminal understands it; it is not a substitute for confirming your broker's own weekend close time against the firm's rule, since the two can differ by design (broker closes a few minutes ahead of the firm's own stated cut-off, for instance). Set InpFlattenMinutesBefore generously if that gap matters to you. OrderClose() is attempted with the input slippage tolerance and no retry loop beyond MQL4's own immediate failure return - a persistent OFF_QUOTES or busy trade context right at the weekly close could leave an order unclosed. Check the Experts log after every weekly close until you are confident this is reliable on your broker. This EA never opens a position - it only closes existing exposure and deletes pending orders.
Expert advisor · MT5 · v1.0 · Free
About Prop Weekend Deadline Enforcer
Prop Weekend Deadline Enforcer is an expert advisor (trading robot) for MetaTrader 5. It has 10 settings, such as Deadline weekday, Deadline hour utc and Deadline minute utc. MQL source code included.
Files in the download: PropWeekendDeadline.ex5, PropWeekendDeadline.mq5, PropWeekendDeadline.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Deadline weekday | WD_FRIDAY | Weekday of the deadline, UTC calendar day |
| Deadline hour utc | 20 | Deadline hour, UTC, 0-23 |
| Deadline minute utc | 45 | Deadline minute, UTC, 0-59 |
| Warn minutes before | 30 | Alert this many minutes before the deadline |
| Flatten minutes before | 5 | Close everything this many minutes before the deadline |
| Close market orders | true | Close open positions when flattening |
| Cancel pending orders | true | Delete pending orders when flattening |
| Magic filter | 0 | Only act on this magic number, 0 = all magic numbers |
| Slippage points | 30 | Deviation tolerance in points for close orders |
| Poll seconds | 15 | How often to re-check the clock, seconds |
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 → Experts.
- 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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Pending Orders · MT5 Expert Advisor · MQL5 Source Code