OrderGuard is an include file for people who write their own Expert Advisors for MetaTrader 5. Its purpose is to make the way an EA sends its orders safe. It is not a robot and it has no trading strategy inside. It comes with a small example EA that shows it in use. It sends market buy and sell orders only.
It does four main things:
Before every order it also makes these checks:
How to use it: put OrderGuard.mqh in MQL5\Include\OrderGuard\ and add #include <OrderGuard\OrderGuard.mqh> to your EA. Create one COrderGuard object and call Init() with your magic number in OnInit(). Then send every order through Open() with a key that names the signal. The example EA uses the direction plus the bar's open time as the key. Open() makes all the checks above and sends the order only if that key has not been traded before.
These are faults I found and fixed on my own trading system. The example EA's entry rule (two moving averages crossing) is only there to give OrderGuard something to guard. It is not a strategy and makes no claim of profit. OrderGuard works on whatever symbol and timeframe the EA that uses it trades. Free to use and change.
Testing: Strategy Tester, H1, 1 September to 20 November 2026, hedging account. EURUSD 13 orders sent and 13 filled, USDJPY 32 and 32, US30 34 and 34, GER30 21 and 21. On all four, no signal was traded twice and no order was refused by the broker. With its memory of past signals switched off on purpose it still made 13 trades with none doubled. Asked for 500 lots, it sent no order. The picture shows these results as a table, with three lines it wrote to the journal.
Not tested: a real restart of a live terminal, a lost connection (the tester is always connected), netting accounts, gold, any other broker, real money.
Inputs of the example EA (defaults):

Pacific Clock - US Pacific time on the chart (PST/PDT)
Shows US Pacific time on the chart, with the broker's time beside it, and the Pacific time of any candle under the mouse.
Lot Size Calculator - Risk Percent to Lots
Calculates the correct lot size from your risk (% of balance, % of equity or a fixed amount) and stop-loss distance. Shows actual risk and margin. Never places trades.
Key Levels: PDH/PDL, weekly and monthly levels, midnight open, Asian range, sweeps
Previous day, week and month high and low, New York midnight open, period opens and the Asian range, with sweep marks and one alert per level. Day from broker or New York time. No repaint, buffers for EAs.
Divergence Detector without repaint: RSI, MACD, Stochastic, CCI, Momentum
Regular and hidden divergences between price and RSI, MACD, Stochastic, CCI or Momentum. Swings confirmed on closed bars, signal on the confirmation bar, lines on oscillator and price. No repaint, buffers for EAs.