Guardian Grid
- Experts
- Versione: 1.0
- Attivazioni: 10
Guardian Grid
Multi-module Expert Advisor with grid trade management for EURUSD H1.
The first order is opened on a signal from one of 18 entry modules: nine Price Action candlestick patterns and nine indicator rules. If the price moves against the position, the EA adds grid orders with a growing lot to the basket and closes the whole basket at a common target.
The EA panel lets you set the lot, grid, exit targets, time, trading direction, which entry modules are enabled, and controls (close all orders, chart button, breakeven lines).
The EA was tested in the MT4 Strategy Tester on EURUSD H1 in "Every tick" mode (modelling quality 99.90%) on 2010–2026 history with real-account costs: spread, swap (BUY −6.74, SELL +1.43 points per lot per night), commission of 5 USD per lot round turn, slippage of ±5 points.
Features:
18 entry modules: Pin Bar, Engulfing, Full Engulfing, Marubozu, Doji, Morning / Evening Star, Gap, Rising Sun / Dark Cloud, Spinning Top, Trending, Keltner, DMI, CCI, RSI, Parabolic SAR, Stochastic, Bollinger Bands, Envelopes.
Entry selection by module priority: if there is a signal in both directions, the side of the higher-priority module is opened.
Grid with a growing lot: each next order is larger than the previous one by an increment — fixed or calculated from the balance (auto lot).
Wider grid step from a set basket order (default — 12 pips from the 5th order): a long move against the position is covered with fewer orders.
Fixed lot or auto lot — the UseAutoLot switch.
Auto lot: the lot is calculated from the balance, with limits on the first lot, the increment and the lot of one order.
A grid order above the per-order lot limit (a large order) is opened in parts (enabled by default): a grid order larger than the maximum lot of one order (MaxOrderLot, or the broker's maximum if it is lower) is opened as several orders, so the lot proportions in the basket — and with them the basket target and closing moment — do not depend on the balance size.
Three exit conditions: single-order target (on every tick); common basket target — by price, excluding swap (on the first tick of a bar; from a set basket order on — a lower target, by default 1 pip instead of 5 from the 3rd order); basket profit as a percentage of the balance — 25% by default, this profit includes swap and commission (on every tick).
Grid orders are placed on the first tick of a bar; optionally — inside the bar, starting from a set basket order.
Tick exit for a large grid (optional): a grid of a set number of orders or more is closed on any tick as soon as the price returns to the basket average price, excluding swap (or moves beyond it into profit by a set number of pips, excluding swap).
Entry filters: market direction, market regime by ADX, monthly hour window for the Trending module (configurable, can be disabled).
Delayed trading start on Monday. On Friday at a set time (before the market closes) the basket is checked: a basket in profit by price, excluding swap, is closed; if the price has moved one step against it, a new grid order is opened; no new baskets until Monday.
Trading direction: both sides, BUY only or SELL only.
Free margin check before every order (for a grid order opened in parts — before each part) and a check of the broker's limit on the number of orders; the basket close is repeated until the basket is fully closed.
Repeated refusals (no margin, order limit) and send errors are written to the journal.
Close all EA orders and stop trading — with a panel input or with a chart button (with confirmation).
Basket lines on the chart: breakeven (including swap and commission), target and tick exit (by price).
Input check at startup; the module that opened the first order is written to the journal.
Recommendations:
Symbol and timeframe: EURUSD H1, both sides.
Settings for EURUSD H1: UseAutoLot = true, GridStepPips = 5, WideStepFromOrder = 9; all others at their defaults (LotStartDivisor = 10000, LotIncDivisor = 5000, WideStepPips = 12, FirstOrderProfitPips = 5, GridBasketProfitPips = 5, 1 pip from the 3rd order, trading window 00:15–23:55).
Trading window — your broker's EURUSD trading session (00:15–23:55 in the tests).
Brokers: ECN brokers, low spread and commission, leverage 1:500.
Trading conditions: ranging market. The main risk is a long one-way move without pullbacks: the basket keeps growing until the price returns.
There is no stop loss or take profit on the orders: the EA closes the basket — at the target or on profit relative to the balance. To close everything manually, use the chart button or the CloseAllAndStop input.
The basket target is calculated by price, excluding swap. The EURUSD BUY swap is negative, so a BUY basket held for weeks may close at its target with a small loss. This is intended: waiting for the price to cover the swap as well keeps the basket open longer and raises the risk.
Minimum deposit:
Conservative risk: 10,000 per every 0.01 of the first lot and 5,000 per every 0.01 of the increment (LotStartDivisor = 10000, LotIncDivisor = 5000).
High risk: 5,000 per every 0.01 of the first lot and 2,500 per every 0.01 of the increment (LotStartDivisor = 5000, LotIncDivisor = 2500).
Test results (EURUSD H1, settings above, auto lot, costs included):
Conservative risk — deposit 10,000, LotStartDivisor = 10000, LotIncDivisor = 5000:
Start 01.01.2010: final balance 209,068 (+199,068), profit factor 2.00, 18,157 trades, 72.4% profitable; maximal drawdown in money — 52,235 (25.82%, May 2026), maximal relative drawdown — 35.49% (February 2020).
Start 04.01.2016: final balance 44,744 (+34,744), profit factor 1.93, 10,916 trades, 70.6% profitable; maximal relative drawdown — 63.70% (August 2022, a BUY basket of 22 orders).
Start 02.01.2020: final balance 27,241 (+17,241), profit factor 1.95, 6,690 trades, 69.2% profitable; maximal drawdown in money — 6,271 (24.03%, May 2026), maximal relative drawdown — 37.37% (February 2020).
High risk — deposit 5,000, LotStartDivisor = 5000, LotIncDivisor = 2500:
Start 01.01.2010: final balance 1,805,814 (+1,800,814), profit factor 2.05, 21,737 trades, 72.1% profitable; maximal drawdown in money — 616,754 (35.00%, May 2026), maximal relative drawdown — 73.84% (February 2020).
Start 04.01.2016: final balance 106,710 (+101,710), profit factor 1.86, 10,852 trades, 70.6% profitable; maximal drawdown in money — 52,073 (51.62%, May 2026), maximal relative drawdown — 65.43% (February 2020).
Start 02.01.2020: final balance 39,330 (+34,330), profit factor 1.96, 6,690 trades, 69.1% profitable; maximal drawdown in money — 17,866 (49.30%, May 2026), maximal relative drawdown — 74.30% (February 2020).
The result depends on the start date: from another date the EA opens other baskets, and the worst of them falls on another part of history. Plan for a drawdown of up to 65% of the deposit at conservative risk and up to 75% at high risk.
Past results do not guarantee future results: a grid without a stop loss can lose the deposit in a long one-way price move.
Parameters:
All switches are true / false; the only mode with several values (TradeDirection) is selected from a list: both directions, BUY only, SELL only.
SetupName: set name, shown in the first line of the panel, in the journal and on the chart.
LOT
UseAutoLot: auto lot — lot from the balance, or fixed lot.
FixedFirstLot: fixed lot of the first order.
FixedLotIncrement: fixed increment — how much larger each next grid order is than the previous one.
LotStartDivisor: auto lot — balance amount per every 0.01 lot of the first order.
StartLotMaxLimit: auto lot — maximum lot of the first order.
LotIncDivisor: auto lot — balance amount per every 0.01 lot by which the next grid order is larger than the previous one.
IncLotMaxLimit: auto lot — maximum lot increment to the next grid order.
MaxOrderLot: maximum lot of one order.
SplitLotAboveMax: a grid order whose lot exceeds the maximum of one order (MaxOrderLot, or the broker's maximum if it is lower) is opened as several orders with one comment: full ones at the maximum, the last one with the remainder. For the basket this is one grid order: the order number, the step, the next order lot and the exit are counted for it as a whole. If disabled, the grid order lot is cut to the maximum, and as the balance grows the last orders of a large basket get a smaller share than the lot ladder intends: the basket average price is farther from the current price, the target is higher, and the basket closes later than it would on a smaller balance. The first order is not split.
EnableLotBalanceCap: auto lot — cap the balance the lot is calculated from.
LotBalanceCap: auto lot — the balance used for the lot is not above this amount if the cap is enabled.
GRID
GridStepPips: grid step — how many pips the price must move against the last basket order for the next one to open.
WideStepFromOrder: basket order number from which the grid step is wider; 0 — off, GridStepPips everywhere.
WideStepPips: grid step from that order on, in pips; for example, with WideStepFromOrder = 5 orders 2–4 are placed at GridStepPips, the fifth and further ones at WideStepPips.
MaxTrades: maximum number of orders in a basket.
MaxSlippagePoints: maximum slippage, in points.
IntraBarKnee: open a grid order on any tick as soon as the price has moved one step; false — only on the first tick of a bar.
IntraBarStepPips: grid step inside a bar, in pips; 0 — the grid step (GridStepPips or WideStepPips).
IntraBarFromOrder: basket order number from which IntraBarKnee applies (2 — from the second).
TickExitOn: tick exit of a large grid inside a bar; false — the grid is closed only on the first tick of a bar.
TickExitFromOrder: basket order number from which the tick exit applies, not less than 2.
TickExitPips: how many pips the price must move beyond the basket average price into profit; 0 — breakeven by price.
EXIT
FirstOrderProfitPips: single-order target, in pips; checked on every tick.
GridBasketProfitPips: grid target — basket profit reduced to the first order lot, in pips; checked on the first tick of every bar.
UseLowerGridTarget: lower grid target from a set basket order; false — GridBasketProfitPips everywhere.
GridDeepFromOrder: basket order number from which the lower grid target applies — 2 or more; 0 — off.
GridDeepProfitPips: lower grid target from that order, pips per first order lot; for example, with GridDeepFromOrder = 3 a basket of two orders closes at GridBasketProfitPips, of three or more — at GridDeepProfitPips. A basket that falls short of its target on the first tick of a bar waits for the next bar; the lower target reduces the risk that during that hour the price starts a long move against the basket.
EnableProfitSpike: close the basket when its profit reaches a set share of the balance.
ProfitSpikePct: basket profit threshold, % of the balance.
TIME & DIRECTION
UseTradingWindow: daily trading window — outside it the EA neither opens nor closes orders (broker trading session); the exit and grid order of a bar that started outside the window are checked on the first tick inside it.
TradingStartTime / TradingEndTime: window start and end, broker server time, HH:MM (end excluded); default 00:15–23:55. If the start is later than the end, the window spans midnight.
UseMondayDelay: delayed trading start on Monday — before the start time there are no new entries or grid orders; closing works.
MondayStartTime: Monday start time, broker server time, HH:MM.
UseFridayStop: basket check on Friday at a set time, as on the first tick of a new bar: a basket in profit by price (the sum of lot × points from the open price is above zero, excluding swap and commission) is closed; otherwise the normal grid exit is checked and, if the price has moved one grid step from the last order, a new grid order is opened; from this time no new baskets are opened until Monday.
FridayStopTime: Friday check time, broker server time, HH:MM; set it slightly before the symbol's market close, for example 23:44 when the market does not trade after 23:45.
TradeDirection: trading direction — both sides, BUY only or SELL only.
UseTrendingHours: monthly hour window for the Trending module; false — Trending at any hour.
TrendingHoursJan … TrendingHoursDec: Trending window for each month in server hours, in the "from-to" format; the end hour is not included; "23-01" — across midnight, "00-24" — the whole day, "-" — no window.
ENTRY MODULES (by priority)
UseTrending, UsePinBar, UseEngulfing, UseFullEngulfing, UseMarubozu, UseDoji, UseStar, UseGap, UseRisingSun, UseSpinningTop, UseKeltner, UseDMI, UseCCI, UseRSI, UsePSAR, UseStochastic, UseBollinger, UseEnvelopes: enable the entry module.
CONTROL & CHART
CloseAllAndStop: close all EA orders (this symbol and Magic Number) and stop trading until the input is set back to false.
ShowCloseButton: "Close all EA orders" button on the chart: the first click arms it for 5 seconds, the second closes all orders and stops trading, the next one resumes trading; the stop is kept after a terminal restart; the button does not work in the tester.
ShowBasketLines: show the basket lines on the chart: breakeven (the price at which the result including swap and commission is zero), the exit target and the tick exit (by price, excluding swap).
OTHER
MagicNumber: magic number of the EA orders.
LogEntryModule: write to the journal which module opened the first order.
Order comments: GG_1 — the first basket order, GG_2, GG_3… — grid orders; a grid order opened in parts (SplitLotAboveMax) is several orders with one comment.
