Loading…

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

About Prop Weekend Deadline Enforcer

Prop Weekend Deadline Enforcer is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 10 settings, such as Deadline weekday, Deadline hour utc and Deadline minute utc. MQL source code included.

Files in the download: PropWeekendDeadline.ex4, PropWeekendDeadline.mq4, PropWeekendDeadline.txt.

Settings

SettingDefaultWhat it does
Deadline weekdayWD_FRIDAYWeekday of the deadline, UTC calendar day
Deadline hour utc20Deadline hour, UTC, 0-23
Deadline minute utc45Deadline minute, UTC, 0-59
Warn minutes before30Alert this many minutes before the deadline
Flatten minutes before5Close everything this many minutes before the deadline
Close market orderstrueClose open buy/sell positions when flattening
Cancel pending orderstrueDelete pending orders when flattening
Magic filter0Only act on this magic number, 0 = all magic numbers
Slippage points30Slippage tolerance in points for close orders
Poll seconds15How often to re-check the clock, seconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Pending Orders · Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria