Bigger lots after a loss is not martingale

Bigger lots after a loss is not martingale

7 August 2026, 11:58
Nice Trader
0
27

A position opens at 0.25 lots. The previous trade on that symbol, closed nine seconds earlier, was 0.10 lots and it was a loss. Something now has about one second to decide whether that is a martingale step and whether to close it.

Given the whole closed history and no deadline, this is an accounting exercise. Given one position, one second and the authority to close it, it is a different problem, and the naive version of the test is wrong in a way that costs money in both directions. A false negative lets the account get martingaled. A false positive closes a disciplined trade for you, at the spread, for nothing.

The obvious test, and why it misfires

The first version everyone writes compares volume. Find the most recent closed losing trade, take the new position, divide new lots by old lots, and flag anything above a ratio.

That test fires on correct behaviour. An EA sizing on fixed fractional risk holds the money constant and lets the lots move with the stop distance.

Take two trades on the same symbol. Trade A closed at a loss: a fifty-point stop at 0.10 lots, one hundred units of account currency at risk. Trade B opens next: a twenty-point stop at 0.25 lots, and also one hundred units at risk. The lot went up two and a half times and the risk did not move at all.

1

Lot ratio 2.50. Risk ratio 1.00. Nothing escalated. A lot-ratio detector calls that martingale, and with enforcement rights it closes trade B for no reason.

The unit is wrong. Lots are not exposure. Lots multiplied by stop distance multiplied by tick value is exposure, and that is what the test has to compare.

Rewriting the test in money

Once you compare money instead of lots, three distinct cases fall out of one.

The position has a stop, and the loser's entry stop is recoverable from history. Compare risk against risk. If the new risk is not genuinely escalated, this is sizing, not martingale, and the correct action is nothing at all. No warning, no log line, no close. If the risk has escalated by the factor you were testing for, that is martingale measured in the unit that matters, and it is worth acting on.

The position has a stop, but the risk on one side cannot be computed. Maybe the loser's entry stop is not in history, maybe the tick value comes back zero. Now the lot ratio is the only evidence you have. It is evidence but not proof, and not enough to close a live trade. Warn and leave it alone.

The position has no stop and it sized up after a loss. This is the clearest of the three. There is no defined loss on the trade, so the escalation is open ended by construction, and nothing has to be reconstructed from history to act.

That middle case is the one most implementations skip. Force closing somebody's live position and writing a line in a log are not the same act, and they should not share a threshold. A monitor that closes on unverified evidence is worse than no monitor, because you stop watching once you trust it.

The baseline is harder to fetch than the comparison

Everything above assumes you can answer one question: what was the last closed losing position for this EA. In MT5 that question has at least four ways to go quietly wrong.

Magic belongs to the deal, not to the position. `DEAL_MAGIC` on a closing deal is the magic of whoever closed it. If a basket utility, a copier or your own tool closes a position, that closer's magic lands on the OUT deal, and any filter walking deals by magic attributes the position to the wrong owner. The owner of a position is the magic on its IN deal. Nothing else.

P/L does not live on one deal. Sum profit, swap and commission across the whole position's deal list. A trade that reads as a small win on the closing deal is a loss once commission and overnight swap land, and a loss is what you are looking for.

A partially closed position already has OUT deals. It is still open. Select by ticket first. If the position still exists it is not a closed loser, whatever the history shows. Also, `DEAL_ENTRY_OUT_BY` is a close. Filtering only on `DEAL_ENTRY_OUT` misses every close-by.

Your own actions poison the baseline. This one took me longest to see. If the guard closes a martingale add, that add becomes a closed losing position in history, and on the next scan it is the most recent loser, so it becomes the next baseline. The guard blinds itself to the doubling it exists to catch. The fix is dull and necessary: stamp your own orders with your own magic number, and skip any position whose OUT deal carries it.

There is a fifth, and it is the sharpest. `DEAL_TIME` and `POSITION_TIME` have one second resolution. An EA that re-enters instantly after a stop out re-enters inside the same second, the fastest doubling on offer, and a strict comparison at second resolution misses exactly that one. Use `DEAL_TIME_MSC` and `POSITION_TIME_MSC`, and compare with greater-or-equal.

What acting on it actually costs

Detection is half the job. If your monitor closes a position and the EA reopens it on the next tick, you have built a machine for paying spread. Anything with enforcement rights needs a per-symbol cooldown, an escalating backoff on failed orders rather than a retry every second, and a daily cap after which it stops and tells you to disable the offending EA. The correct end of a close and reopen war is a human turning something off.

Two log lines from the same EA and symbol, with different verdicts.

Each line records the timestamp, the action taken, the symbol and direction, the lot, the price, the stop and the reason, with the multiple against the previous trade in brackets. A warning line means the entry was stopped before it reached the broker. A close line means an existing position was flattened. Both say in words why, so the log is readable months later without the code beside it.

The first has a stop and unverifiable risk, so it is reported and left alone. The second has a stop-loss field of zero, and that is why it was closed.

The implementation, and its limits

All of the above is in Martingale Firewall TechnoTrader, a utility that runs alongside any EA, copied signal or manual trading. It opens no trades of its own. WARN mode reports and touches nothing. ENFORCE mode closes the size-up-after-loss trades and grid adds that fail the risk test above, and attaches a hard stop to a naked position.

The limits are worth stating plainly. It makes no performance claim and cannot make a losing strategy profitable. On a netting account a net position cannot be surgically unwound, so martingale and grid enforcement drop back to WARN there and only the protective stop still gets attached. It conceals nothing from anyone: every action is an ordinary order carrying its own magic number, written to a CSV audit log you can read.

No martingale. No grid. No averaging down. Holding yourself to that is one thing. Holding a bought EA to it, while it is running, on money that is already at risk, is what the work above is for.

Martingale Firewall TechnoTrader is on the MQL5 Market at $49. https://www.mql5.com/en/market/product/188012