Experts: XANDER Grid XAUUSD - page 4

Honestly, it's better to simply avoid this EA and grid/martingale systems altogether. In my experience, no matter how many filters, cooldowns, or max drawdown settings you apply — which is absolutely fundamental with any system or strategy you use — these specific strategies remain a ticking time bomb, especially on volatile assets like Gold. Personally, I completely avoid grid systems in my trading because if you want to trade professionally and protect your capital in the long run, they are just not worth the risk

Francesco Cerullo #:

Honestly, it's better to simply avoid this EA and grid/martingale systems altogether. In my experience, no matter how many filters, cooldowns, or max drawdown settings you apply — which is absolutely fundamental with any system or strategy you use — these specific strategies remain a ticking time bomb, especially on volatile assets like Gold. Personally, I completely avoid grid systems in my trading because if you want to trade professionally and protect your capital in the long run, they are just not worth the risk

I agree, and it appears that you have enough experience to realize that fact. TBH, the max loss input that I added proves it beyond a reasonable doubt.

I tested the edited code (default settings) on EURUSD, M1, real ticks, 5 years:

graph

442.67 USD net profit. Considering how much the EA gave back as the test progressed, it very easily could have blown up if the test had been started a few years later. There are certainly simpler ways to earn a mere average of 88.53 USD per year.

And that was on the predominantly rangebound Fiber (EURUSD). As Francesco Cerullo forecasted in Post #31, the same test on XAUUSD blew up sooner.

More like a Pontiac Aztek with a square tire.

Selvam M #:
Using this EA during moderate market conditions would be excellent; however, it should be closed manually. In other words, once it yields a certain amount of profit, it is advisable to manually close it with a specific low loss.

Thanks for your suggestions. I will think about it.
Ryan L Johnson #:

I tested the edited code (default settings) on EURUSD, M1, real ticks, 5 years:

442.67 USD net profit. Considering how much the EA gave back as the test progressed, it very easily could have blown up if the test had been started a few years later. There are certainly simpler ways to earn a mere average of 88.53 USD per year.

And that was on the predominantly rangebound Fiber (EURUSD). As Francesco Cerullo forecasted in Post #31, the same test on XAUUSD blew up sooner.

More like a Pontiac Aztek with a square tire.

Try CCY pairs, with H1 time frame.
Zack Burger #:

Pls Share the update and the set file.



Thank you Zack. The update and the set file are coming on the 26th, just a couple of days away. Follow my profile and add me as a friend so the notification reaches you the minute it is up.
TradeGladiator #:
it is very useful if there is breakeven, basket close and also trailing SL features can be added. I am also trying to add these features to this bot to test, but still not yet fully operated. if you have this featured mql file so pls share so I test it.


Thank you for the ideas TradeGladiator. Breakeven, basket close and trailing are exactly the direction I am taking this. A new update is coming on the 26th, so stay tuned. Follow my profile and add me as a friend so the notification reaches you the moment I publish it.
José do #:
very good


Thank you José, glad it is working well for you. A new update is coming on the 26th, so stay tuned. Follow my profile and add me as a friend so you get notified the moment it is published.
Yasser Ramadan #:
ROOT CAUSE ANALYSIS
─────────────────────────────
Three structural bugs were identified in OnTick():

1. Infinite re-entry loop after grid close
   When a grid cycle completed and all positions were closed, the open-position counter (b or s) reset to zero. On the very next tick, the condition (b == 0) evaluated as true and immediately triggered a new entry — which was then closed — which reset b to zero again. This loop repeated dozens of times per second because OnTick fires on every price change for XAUUSD.

2. Overlapping dual-order execution in Partial Close mode
   The Partial Close logic issued two trade orders (PositionClosePartial + PositionClose) sequentially in the same tick, with no delay between them. The server had not finished processing the first order before the second was sent, causing order conflicts and unintended re-entries.

3. No cooldown / rate-limiting between trade actions
   There was no mechanism to track the last trade timestamp. OnTick re-evaluated entry and exit conditions on every single tick with no minimum gap enforced, making the above two bugs catastrophic under volatile market conditions.

─────────────────────────────
FIX APPLIED (v1.1)
─────────────────────────────
1. Added a global datetime variable g_LastTradeTime to record the timestamp of every open and close action.

2. Added a user-configurable input xs_CooldownSec (default: 5 seconds). OnTick now returns immediately if (TimeCurrent() - g_LastTradeTime < xs_CooldownSec).

3. Added Sleep(200) between the two Partial Close orders to allow the server to process the first order before the second is sent.

4. Added a hard return statement after every close block so OnTick cannot continue to the entry logic in the same tick a position was closed.

─────────────────────────────
KEY TAKEAWAY
─────────────────────────────
The bug did not appear immediately — it only triggered after several hours once the grid had enough open positions to reach its close condition for the first time. Any Grid EA without a post-close cooldown and single-tick re-entry guard is potentially exposed to the same failure mode, especially on a fast-tick instrument like Gold.

Happy to share the full source code (v1.0 and v1.1) for review if useful.



This is what claude.ai said



Thank you Yasser, I really appreciate you digging into the code and sharing it. The build coming on the 26th addresses exactly that, the re-entry loop and the overlapping closes, with a cooldown guard. Follow my profile and add me as a friend so you catch it the moment it is live.
MuthuVijayan Thirupathi. #:
Can we have the updated version of this


Thank you. The updated version lands on the 26th, so stay tuned. Add me as a friend and follow my profile so the notification reaches you as soon as I publish it.