WARNING: this EA can lose your whole deposit. It holds several positions together in one direction: a basket that adds positions when price moves against it. That is grid-like risk. Most baskets close with a small profit, and from time to time one basket closes with a large loss.
- You can lose up to 100 % of your deposit. Gold moves fast and the account uses leverage.
- A big account is not protected. A strong one-way move in gold can take a large account too, not only a small one. More money in the account does not lower the risk. Only a smaller lot for your balance does.
- One loss can erase many wins. The win rate on the panel will look very high. One basket that closes at its stop can take back the profit of dozens of winning baskets. A high win rate does not mean low risk.
- Every basket has a stop loss, and the EA holds it. The EA watches the stop and closes the basket itself. The stop is not placed at the broker. If the terminal or VPS is off, the connection drops, or price gaps (for example after a weekend), a basket can lose more than the figures below.
- Past tests do not predict the future. The figures below come from past data (real ticks, one broker, January 2024 - October 2026). The EA was built on these same years, so later years can be worse. Other brokers have other prices, spreads, commissions and swaps.
- Start on a demo account for 2-4 weeks. Check that the EA trades, that the panel shows "LICENSED", and that the losses you see are ones you can live with.
- Start small. The learning floor is a cent account with 50-100 USD (= 5,000-10,000 USC) and Risk mode Low. On a cent account every money figure (balance, panel, the tables below) counts in USC (US cents). Start small to learn how the EA behaves, not to make money.
- Ask support before you change any setting: https://m.me/forexreviewth
- This EA is not a safe investment, it is not passive income, and no result is guaranteed. Trade only money you can afford to lose.
What a basket that closed at its stop (a "full-basket loss") cost in the tests, at 0.01 lot per position:
| At 0.01 lot per position | |
|---|---|
| Typical full-basket loss (median) | about 121 USD |
| Worst full-basket loss | 211 USD |
| Deepest fall of closed results | 361 USD (May - August 2025) |
| Full-basket losses in the tests | 36 in 34 months (8 in 2024, 22 in 2025, 6 in January - October 2026) |
- The worst full-basket loss was about 1.7 times the typical one: in a fast market a basket can lose more than usual.
- The deepest fall counts closed baskets only. The floating loss of an open basket comes on top of it.
- Real ticks, one broker. A live stop can close at a worse price (slippage).
- The risk mode scales these figures with your lot: at 0.02 lot per position every figure doubles, at 0.03 it triples, and so on. The % for each risk mode is in "Risk modes" below.
XAU Layer Engine
Expert Advisor for MetaTrader 5, gold (XAUUSD) only. 16 entry modules on one chart open one basket at a time, and a basket can hold up to 5 positions in the same direction.
1What the EA does
▼- It trades gold automatically when the conditions of one of its 16 modules are met. The panel names the modules A01-A08 (group A) and B01-B08 (group B). Each module trades one side only, buy or sell.
- Only one basket is open at a time. While a basket is open, no other module starts one.
- A basket starts with one position. If price moves against it, the EA can add positions in the same direction, up to 5 in total. Every position uses the same lot. The lot does not grow from one position to the next (no martingale).
- Every basket has a stop loss. Most baskets close with a small profit. A basket that keeps going the wrong way closes at its stop loss with all its positions.
- If the free margin is too small to add the next position, the basket adds no more positions and its stop loss still applies.
- It rests on some days (see "Days with no new baskets").
2What you need
▼- MetaTrader 5 on Windows (a PC or a Windows VPS) and a hedging account. A netting account is refused: the EA stops at start with the message "a basket needs separate positions: use a hedging account" in the Experts tab.
- A chart of your broker's gold symbol: XAUUSD, or the same with a suffix such as XAUUSDm. Any timeframe. On a symbol that is not gold the EA does not start.
- A terminal that runs 24/5: a VPS, or a computer that is always on and online. The EA holds each basket's stop itself, so a terminal that is off cannot close a basket.
- WebRequest allowed for the licence check: Tools > Options > Expert Advisors > tick "Allow WebRequest for listed URL" and add all three:
https://zab-license.bangzeed.workers.devhttps://zab-license.vercel.apphttps://license.forexreviewth.com
- A licence for your account number: send the account number to support (https://m.me/forexreviewth). A demo account needs no licence. On a real account the first start gives a 3-day trial; the dashboard then shows TRIAL with its end date. Without a licence the EA opens no new basket. A basket that is already open is still managed to its end.
- Enough free margin for 5 positions at your lot. Another EA on the same account uses margin too.
3Install
▼- In MT5 open File > Open Data Folder, copy
XAULayerEngine.ex5intoMQL5\Experts\, then right-click Experts in the Navigator > Refresh. - Open a chart of your gold symbol and drag XAU Layer Engine onto it.
- In the Common tab tick "Allow Algo Trading". In the Inputs tab set the inputs (keep the defaults at first). Press OK.
- Turn on the Algo Trading button in the toolbar. The dashboard appears on the chart, and the Experts tab shows a start line with the version, the server clock and the risk mode.
- Run one copy per account. A second copy on another chart needs its own Magic number (see Inputs) and doubles the margin in use and the risk.
4Inputs
▼| Input (as MT5 shows it) | Default | Allowed | What it does |
|---|---|---|---|
| Money | |||
Risk mode | Low | High / Mid / Low / Fixed lot | How the lot is chosen. High, Mid and Low grow the lot with your balance (table below). Fixed lot uses the same lot at any balance |
Fixed lot (only when Risk mode = Fixed lot) | 0.01 | your broker's minimum lot and up | The lot of every position in Fixed lot mode. Other modes ignore it |
| Filters | |||
Max spread for a new basket, in price (0 = off) | 0 | 0, or a price such as 0.50 | A new basket does not start while the spread is wider than this. Same unit as "Spread" in the panel footer. 0 = no check |
Use the extra pause dates below | false | true / false | Turns your own pause dates on |
Extra pause dates: yyyy.mm.dd,yyyy.mm.dd | empty | dates in this format | No new basket on these days, for example 2027.05.03,2027.05.04. A comma between dates. The built-in pause days work without this |
| Modules | |||
Module group A (A01-A08) | true | true / false | Switches the 8 modules of group A on or off. Off stops new baskets from these modules. A basket that is already open is still managed to its end |
Module group B (B01-B08) | true | true / false | The same for group B |
| General | |||
Magic number | 52003100 | a whole number | Marks the EA's positions. Change it only when another EA on the account uses the same number, and never while a basket is open. A new number also starts a new dashboard history |
Show the dashboard | true | true / false | Panel on the chart. Off does not change trading |
Server hours ahead of New York when it cannot be read | 7 | whole hours | Used only when the EA cannot read the server clock itself. Leave 7 unless support tells you otherwise |
| Dashboard | |||
Start the dashboard history from now (set back to false afterwards) | false | true / false | Starts the panel's statistics again: set true once, press OK, then set it back to false. While it is true, every restart starts a new history |
Dashboard size (0.4 - 1.5; A- / A+ on the panel) | 1.0 | 0.4 - 1.5 | Starting size of the panel. On a live chart, A- / A+ change the size (0.6 - 1.4) and the chart keeps the size you chose |
Dashboard X (px) / Dashboard Y (px) | 10 / 20 | pixels | Position of the panel from the top-left corner of the chart |
Risk modes (Low / Mid / High)
The lot grows with your balance: 0.01 lot for every full amount of balance shown below. The % columns are for a balance of exactly one, two, three ... times that amount, which is the worst point. A balance in between risks less.
| Mode | 0.01 lot per | Typical full-basket loss | Worst full-basket loss | Deepest fall (closed results) |
|---|---|---|---|---|
| Low (default) | 6,000 USD | 2.0 % | 3.5 % | 6.0 % |
| Mid | 3,000 USD | 4.0 % | 7.0 % | 12.0 % |
| High | 1,000 USD | 12.1 % | 21.1 % | 36.1 % |
Example, Low mode: balance 6,000 USD → 0.01 lot per position; 11,999 USD → still 0.01; 12,000 USD → 0.02.
Fixed lot
Every position uses the lot you set, whatever the balance. When the balance falls, the lot does not, so the risk in % grows during a losing run.
| Lot per position | Typical full-basket loss | Worst full-basket loss | Deepest fall (closed results) | Balance with the risk of High mode |
|---|---|---|---|---|
| 0.01 | 121 USD | 211 USD | 361 USD | 1,000 USD |
| 0.05 | 605 USD | 1,055 USD | 1,805 USD | 5,000 USD |
| 0.10 | 1,210 USD | 2,110 USD | 3,610 USD | 10,000 USD |
- The lot is rounded down to a size your broker accepts and kept within the broker's smallest and largest lot. The Experts tab says so when it changes your value.
- If the balance at start is under the right-hand column, the Experts tab shows a WARNING line. The EA still trades.
- STATS > "Balance per 0.01 lot" shows how much balance you hold now for each 0.01 lot. Compare it with the risk mode table.
- On cent and non-USD accounts the Fixed lot is used as typed. The money per lot is then different from this table.
Cent accounts and other account currencies
The risk modes convert for you. The guard "0.01 lot = ..." (MODULES tab) shows what 0.01 lot earns for each 1.00 move of the gold price, in your account money. The EA multiplies the amounts of the risk mode table by it, and the panel footer shows the result, for example "0.01 lot per 6,000 USC".
| Account | Guard "0.01 lot = ..." | Low mode: 0.01 lot per | Typical full-basket loss at 0.01 lot |
|---|---|---|---|
| USD | 1.00 | 6,000 USD | about 121 USD |
| Cent (most brokers) | 1.00 | 6,000 USC (= 60 USD) | about 121 USC (= 1.21 USD) |
| Cent where 0.01 lot earns 100 USC | 100.00 | 600,000 USC (= 6,000 USD) | about 12,100 USC (= 121 USD) |
| THB (about 33 THB per USD) | about 33 | about 198,000 THB | about 4,000 THB |
| EUR | a little under 1.00 | a little under 6,000 EUR | a little under 121 EUR |
- On a normal cent account the learning floor of 5,000-10,000 USC gets 0.01 lot in Low mode. At 5,000 USC that is a little more risk than the Low row: a typical full-basket loss is about 2.4 % of the balance and the worst about 4.2 %.
- Test a cent or non-USD account on a demo of the same account type first, and check that the guard shows the value in this table.
- If the Experts tab ever shows a line with "do not trust lots", do not trade on that account. Contact support.
5Days with no new baskets
▼The EA does not start a new basket:
- on some scheduled major US news days,
- before the weekend close on Friday,
- in some market conditions,
- on your own extra pause dates (see Inputs).
A basket that is already open is still managed on these days. The panel then shows PAUSED (or HOLD) with a short reason.
The news days are built in through 2027. On a live chart the EA also reads MetaTrader's economic calendar, so a news day that moves is followed. If the Experts tab says the news calendar is not available, the EA uses its built-in dates. Ask support once a year for the newest build, so the built-in days stay up to date.
6Broker and server time
▼The EA was built and tested on the server clock most MT5 brokers use: GMT+2 in winter, GMT+3 in summer. The EA reads your server's clock by itself and shows it as the guard "Clock NY +7" (MODULES tab; +7 = that common broker clock) and in the footer (server time and New York time).
On a server with another clock the EA converts by itself. The guard then shows another number in amber: that is information, not an error. On a test server with another clock about 84 % of the entries came at the same minute as on the reference server; the rest differ because each broker's prices differ. Profit always differs with each broker's spread, commission and swap.
If your broker's gold has no daily trading break, or the guard shows a number that looks wrong, test on demo first and ask support. The input "Server hours ahead of New York when it cannot be read" is used only when the EA cannot read the clock.
7The dashboard
▼Figures cover this run: from the moment the EA was first attached with this Magic number on this symbol in this terminal. They survive a restart and a change of inputs. They count closed baskets after swap and commission, dated by server time, and a basket counts once, when its last position closes. The input "Start the dashboard history from now" starts a new run.
Click the header to fold or open the panel. A- / A+ change the size. The panel remembers its tab, size, fold and curve range for each chart. Turning the panel off does not change trading.
Header
From left to right: logo and name; the line "symbol · 16 modules · risk mode · version"; the licence card; A- / A+; the status.
Licence card (centre)
| Shows | Means |
|---|---|
| LICENSED | active; the server name follows |
| TRIAL | the trial end date and the days left; amber in the last 14 days |
| CHECKING | the EA is asking the licence server |
| CACHED · CHECKING | the EA uses the last known answer while it asks again |
| NOT LICENSED · MANAGE ONLY | no new basket; an open basket is still managed to its end |
| EXPIRED · MANAGE ONLY | the licence ended; same as above |
| STRATEGY TESTER | the licence is not checked in the tester |
Status (top right)
| Shows | Means |
|---|---|
| RUNNING | no basket is open; the modules wait for their conditions |
| BASKET OPEN | a basket is open and the EA manages it |
| BASKET · NO MARGIN | the free margin is too small to add the next position. The basket adds no more positions and its stop loss still applies. If you see this often, the balance is too small for the lot or another EA uses the margin |
| PAUSED · reason | no new basket now: "news day", "market conditions", "Friday close" or "extra pause date"; see "Days with no new baskets" |
| HOLD · reopening | the minute the market reopens after its daily break; no new basket in that minute |
| NOT LICENSED | no licence: no new basket; an open basket is still managed |
| CLOSING | the EA is closing a basket but the market is closed; it tries again by itself |
| CHECK POSITIONS | there are positions with this EA's Magic number that it cannot match to a module. The EA does not manage them: close them by hand, then the EA starts again |
| STARTING | the first moments after start |
Left column (on every tab)
- THIS MONTH: result of the month, % of the balance at the month start, a bar with the days in profit, and the number of baskets.
- BALANCE: curve of the closed balance. WEEK / MONTH / ALL choose the range. Bottom left: the start date of the range; bottom right: the change over the range.
- TODAY: today's result and baskets. OPEN RESULT: the floating result of the open basket and how many positions are open. SINCE START: return of the run in %. DRAWDOWN: the fall from the highest closed balance, now and the largest of the run.
- BASKET NOW:
- A basket is open: the module (for example B04), BUY or SELL with the lot per position, the open result, how long it has been open, one dot for each position ("3 / 5 layers") and the price of the last position. If the next position cannot be added for margin, the line says "no margin for the next layer" in red. "closing, market closed: retrying" means the EA closes the basket as soon as the market opens.
- No basket: "waiting for a signal" (blue), "paused: reason" (amber), "no licence, no new basket" (red), or another short state. Top right: how many modules are working at this moment ("6 of 16 modules active"). Below: the lot of the next basket.
- "N positions, no module comment" (red): positions with this EA's Magic number that it cannot manage. Close them by hand.
Tabs (right card)
- MONTH: calendar of the month, Monday to Friday. Each day shows its result and baskets, green for profit, red for loss; today has a gold ring. The WEEK column holds week totals. The line on top shows the month result, days in profit, best day and worst day. The arrows go back to earlier months of the run; LATEST returns to this month.
- YEAR: the 12 months of the year. Each box shows the result, the % of the closed balance at the month start, the baskets and the days up. The line on top shows the year result and %, months in profit, best and worst month. The arrows go to earlier years; a click on a month opens its calendar.
- MODULES: the 16 modules with ID, SIDE (buy or sell), NOW, TODAY, MONTH, BASKETS, WIN%, LOSS (losing baskets) and LAST 20 (one bar per basket, green win, red loss, newest on the right). The module of the open basket is highlighted. NOW shows:
| NOW | Means |
|---|---|
| basket 3 / 5 | this module's basket is open, with 3 of 5 positions |
| another basket open | another module has the basket |
| waiting signal | working; the time after it counts since the last basket or pause ended |
| resting | the module is not working at this time |
| entry refused | the module's conditions were met but the basket could not open (for example spread, margin or a broker refusal); see the Experts tab |
| paused reason (amber) | no new basket now |
| no licence | no new basket without a licence |
| switched off | its group is off in the inputs |
- GUARDS (bottom of the MODULES tab):
| Guard | Means |
|---|---|
| Gate open / Gate: basket open / Gate: reason | whether a new basket may start now, or why not |
| Spread | spread now; amber when it is above your Max spread |
| Margin | margin in use as % of equity; red when there is no margin for the next position |
| Licence OK / Licence: manage only | licence state |
| Clock NY +7 | your server's clock against New York; green at +7, amber on another clock (see "Broker and server time") |
| 0.01 lot = 1.00 | what 0.01 lot earns per 1.00 move of gold, in your account money; green at 1.00 (see "Cent accounts") |
- STATS: "This run" since the start date, with trading days and baskets. PROFIT FACTOR (gross profit / gross loss), WIN RATE (with the losing baskets), RETURN (% on the run start balance), DRAWDOWN (largest on closed results, and now). The balance curve of the run marks the largest drawdown. BEST / WORST: best day, worst day, losing days in a row, biggest losing basket, green days. RUN + MONEY: run started, closed P/L, risk mode, lot of the next basket, balance per 0.01 lot.
Footer
Balance, equity, spread now / recent average, ping, server time · New York time. Right: "0.01 lot per ..." is the balance for each 0.01 lot of your risk mode, in your account money (in Fixed lot mode: the balance you hold now for each 0.01 lot).
8Restart, VPS move, updates
▼Restart. You can close the terminal, restart the VPS or change inputs at any time. On start the EA finds its open positions by the Magic number and its own position comments and goes on managing the basket, without opening it twice.
- Do not change the Magic number while a basket is open.
- Do not close, add or change the EA's positions by hand. If you decide to close a basket by hand, close all of its positions together.
- If the panel shows CHECK POSITIONS, close the positions it found by hand; then the EA starts again.
VPS move
- Move when no basket is open (status RUNNING or PAUSED), if you can.
- Remove the EA from the old terminal (or turn off Algo Trading there) before you start it on the new one, so two terminals never manage the same basket.
- Install on the new terminal with the same inputs and the same Magic number. An open basket is picked up. The dashboard history starts again on the new terminal.
Updates
- Get new builds from support only. Ask once a year, so the built-in news days stay up to date.
- Update when no basket is open, if you can. Copy the new
XAULayerEngine.ex5over the old one inMQL5\Experts\. MT5 reloads it on the chart; if not, remove the EA from the chart and attach it again. - Check that the header shows the new version and that the inputs are still yours. With the same Magic number on the same terminal the dashboard history goes on.
Before you trade real money, check
- 2-4 weeks on a demo of the same account type (cent, standard, your account currency).
- The licence card shows LICENSED, and the guard "0.01 lot = ..." shows the value for your account type.
- You worked out your own worst case: for each 0.01 lot per position, 211 for one basket and 361 for a losing run (USD, or USC on a cent account), and you can accept losing that. Live losses can be bigger.
- The terminal runs on a VPS or an always-on computer.
9Support
▼Support: https://m.me/forexreviewth