Page 1 of 1

Calendar API into EA for auto-disable

Posted: Tue Sep 15, 2026 12:09 am
by LondonScalper
Calendar API into an EA for auto-disable -- practical notes.

I want algos flat around tier-1 events without relying on me remembering. Calendar inject / API disable flags help -- with caveats: clock sync, event importance mapping to your symbols, and fail-safe if the API dies (fail closed: disable trading).

Design
Blackout minutes configurable per event class. Log every disable/enable. Do not auto-reenable into a still-wide spread; add a spread gate after the window.

Automation of discipline beats heroic overnight monitoring. Test on demo during a known CPI week before trusting live.

What fail-safes do you use when the calendar feed glitches?

Keep a manual override you can hit without redeploying code. APIs fail on the day you need them. A big red disable -- tested -- is part of the system. Automation should reduce babysitting, not create a new single point of failure you ignore.

I am interested in how others on this desk handle the same problem without turning it into folklore. Concrete rules and log fields beat slogans. If you have a version of "Calendar API into an EA for auto-disable" that survived contact with live sessions, what does the rule look like on a sticky note -- and what did you try that failed?

Re: Calendar API into EA for auto-disable

Posted: Sat Oct 03, 2026 4:44 am
by PropScalpDesk
Fail closed, as you say, but also define what "glitch" means in code. My check is staleness: if the feed hasn't updated in a set number of hours, or returns no events for a week that obviously has some, the EA treats it as down and stops opening trades. An empty response looks like "no news today" unless you specifically test for it.

I also keep a small fallback file with the next few weeks of tier-1 times typed in by hand on Sunday. Hard-coded rules like "NFP is the first Friday" are not safe; the US government shutdown in October 2025 delayed the scheduled jobs releases, and a fixed rule would have blacked out the wrong days.

If you're on MT5, the built-in economic calendar functions (CalendarValueHistory and related) are worth a look as a second source. It's MetaQuotes data, so not independent of the platform, but it doesn't depend on a third-party API key staying valid. Comparing the two sources each morning flags most problems before the session.

Re: Calendar API into EA for auto-disable

Posted: Tue Oct 13, 2026 8:48 am
by Fairman
PropScalpDesk wrote: Comparing the two sources each morning flags most problems before the session.
Good idea, and one practical detail: which time zone do both sides get compared in? The MT5 calendar returns event times in trade server time, which on most brokers is GMT+2 in winter and GMT+3 in summer, while a hand-typed fallback file is usually in London time. Most of the year the gap is two hours, but Europe and the US change clocks on different weekends, and the broker's server usually follows the US switch, so for a week or two in spring and autumn the offset is different. The next one is close, with Europe moving back on 25 October and the US on 1 November. Does your check convert both to UTC, or does it just compare event counts per day?

Re: Calendar API into EA for auto-disable

Posted: Fri Oct 16, 2026 8:19 pm
by Shadow Trader
Converting both to UTC is the safer choice, and it is less work than it sounds. The EA computes the server offset as TimeTradeServer minus TimeGMT, rounded to the nearest half hour, and subtracts it from every calendar time before comparing.

The trap there is using TimeCurrent instead. It returns the time of the last quote, so on a Sunday check before the market opens it still shows Friday evening and the offset comes out wrong by days.

I keep the fallback file in UTC directly rather than London time. Typing it on Sunday means converting once by hand, but the comparison then never depends on which country changed its clocks that weekend.

For the 26 to 30 October window, a broker on New York close time should show a three hour gap to London instead of two. My EA prints the computed offset to the log each morning, so a wrong value shows up before the first trade instead of after a missed blackout.

Counting events per day is still worth keeping as a second check. A day with a known release and zero events in either source is the clearest sign that something has gone stale.

Re: Calendar API into EA for auto-disable

Posted: Sat Oct 17, 2026 10:17 pm
by Shadow Trader
One limitation that caught me when testing the blackout logic is that the MT5 calendar functions return nothing inside the strategy tester. The EA saw an empty calendar for every day of the backtest, so the staleness check PropScalpDesk describes would have treated the whole history as a feed outage.

My workaround is a CSV of past events, written once by a small script on a live terminal, which the EA reads only when it detects it is running in the tester. Live trading never touches that file.

Open positions at the start of a blackout need a rule as well. Mine closes anything with less than 5 pips of profit two minutes before a tier one release, and leaves trades already well ahead running with the stop moved to entry.

The re-enable side gets its own gate, as LondonScalper says. I wait until the spread has stayed under 1.2 times its usual level for 60 consecutive seconds, since one tight tick in a wide market is easy to mistake for normal.

Rescheduled releases are the last case worth coding for. Matching on the event ID rather than on the time means a moved release keeps its blackout instead of leaving a duplicate behind.