Consecutive Loss Cooldown
Losing streaks are when discipline slips - size creeps up, entries get rushed, and a bad run turns into a blown week. This EA counts consecutive closed losers (net of profit, swap and commission) from the newest trade backward, and the instant one trade nets zero or better the streak resets, exactly the way a trader counting losses by hand would reset at the first win. Once the streak reaches the configured length, a cooldown window opens measured from the close time of the LAST loser in the streak, not from the time the EA happens to notice it. No program running alongside another EA in the same terminal can reach into that other EA's OrderSend call and refuse the order before it exists - nothing can, that is simply how MetaTrader 4 is built - so enforcement works the only way it honestly can: the position is allowed to appear and is then closed again immediately, with the exact reason logged and alerted. An optional terminal global variable is published while the cooldown is active, holding the timestamp the cooldown ends. A companion EA that checks for this variable can choose to skip its own entries voluntarily instead of relying purely on the after-the-fact close, though nothing requires it to. Notes and limitations This EA cannot prevent another program's order from being sent - it can only close the position again after it appears, which means a very fast scalping EA could, in principle, open and close inside the same tick before this EA reacts. It also cannot see trading done from a different terminal or account. The streak is measured from closed trade history only; it does not attempt to guess at floating positions that have not closed yet. Treat it as a safety net for a human or a well-behaved automated strategy, not as a guaranteed veto.
Expert advisor · MT4 · v1.0 · Free
About Consecutive Loss Cooldown
Consecutive Loss Cooldown is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Consecutive losses, Cooldown minutes and Magic filter. MQL source code included.
Files in the download: ConsecutiveLossCooldown.ex4, ConsecutiveLossCooldown.mq4, ConsecutiveLossCooldown.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Consecutive losses | 3 | Losers in a row (net profit+swap+commission < 0) that triggers the cooldown |
| Cooldown minutes | 60 | Minutes, from the close of the last loser, during which new entries are refused |
| Magic filter | -1 | Magic number filter for both the streak and the entries it blocks (-1 = every magic number) |
| This symbol only | false | Restrict the streak and the block to this chart's symbol only |
| Publish global flag | true | Publish a terminal global variable other EAs can poll to self-pause |
| Dry run | false | true = alert only, never closes - use to observe before enforcing |
| Max retries | 5 | Attempts per close before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
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: Alerts · MT4 Expert Advisor · MQL4 Source Code