Global Retry Budget Manager
A single EA retrying a failed OrderSend a handful of times is normal and expected. The problem is several independent EAs on the same terminal each doing exactly that at the same moment - each one looks reasonable in isolation, but the server sees a burst of requests that can trip a temporary ban for the whole terminal, not just the EA that triggered it. MQL4 gives no program a way to call directly into another program or intercept its OrderSend calls, so there is no way to build a true enforced rate limiter across independent EAs. What this does instead is own a small set of namespaced GlobalVariable slots - a rolling window length, a maximum retry count for that window, a live counter, and an exhausted flag - that any cooperating EA can read before it retries a failed trade request, and increment as it spends retries. This program owns the window bookkeeping: it rolls the window over on schedule, resets the counter, and raises the exhausted flag once the shared budget for the current window is spent. This is honestly advisory. A non-cooperating EA that ignores the published flag is not physically prevented from retrying anyway - the value of this tool is entirely in how many of the EAs on a given terminal are written to check it first. A demo "Simulate Retry" button is included so the shared counter's behaviour can be observed on one chart without needing a second EA already wired up to it. Notes and limitations - Advisory only. This program cannot stop a non-cooperating EA from retrying past the published budget - MQL4 has no mechanism for one program to intercept another's trade requests. - GlobalVariables are shared across every chart and EA in this terminal instance, but are not shared between different running terminal instances (e.g. two separate MetaTrader installs) or written to disk beyond the terminal's own GlobalVariable store. - Terminal-native GlobalVariables are removed automatically after 4 hours without being read or written; a terminal left idle that long will need this EA (or a cooperating one) to re-touch the slots to keep them alive, which happens naturally as long as at least one attached EA is running. - Run only one copy of this manager per terminal. Two copies on different charts with the same InpBudgetName both reset the window on InpResetOnInit and will fight each other's bookkeeping.
Expert advisor · MT4 · v1.0 · Free
About Global Retry Budget Manager
Global Retry Budget Manager is a script for MetaTrader 4. It has 5 settings, such as Budget name, Max retries per window and Window seconds. MQL source code included.
Files in the download: GlobalRetryBudget.ex4, GlobalRetryBudget.mq4, GlobalRetryBudget.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Budget name | GRB | Namespace prefix for the shared GlobalVariable slots |
| Max retries per window | 10 | Retries every cooperating EA may collectively spend per window |
| Window seconds | 60 | Length of the rolling budget window, seconds |
| Reset on init | false | true = zero the shared counter when this chart attaches |
| Show button | true | true = draw a "Simulate Retry" test button on the chart |
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: MT4 Expert Advisor · MQL4 Source Code