Experts: XANDER Grid XAUUSD

 

XANDER Grid XAUUSD:

Bidirectional grid EA for Gold (XAUUSD). Ideal for ProCent accounts. Includes Daily Profit Target and Max Drawdown protection.

XANDER Grid XAUUSD

Author: Cristhian Alexander Gaibor Cuasquer

 
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.
 
very useful and aggressive EA. Tested it for around 8 hours in a competition on a 100k account. Was standing on just over $6k profit, when it went all haywire, opening and closing deals like crazy. Around 3-4 per second. Smashed the $6k profit to -$1966 in about 13 seconds... Don't know why, but even when i reinstalled it, the same happened. Other that that, it was an amazing EA to try out and would like to keep using it. Please let me know, when the issue is sorted
 
very good
 
NexLuxe #:
very useful and aggressive EA. Tested it for around 8 hours in a competition on a 100k account. Was standing on just over $6k profit, when it went all haywire, opening and closing deals like crazy. Around 3-4 per second. Smashed the $6k profit to -$1966 in about 13 seconds... Don't know why, but even when i reinstalled it, the same happened. Other that that, it was an amazing EA to try out and would like to keep using it. Please let me know, when the issue is sorted
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

Files:
 

Pls Share the update and the set file.

 
Zack Burger #:

Pls Share the update and the set file.

OK
Files:
 
Can we have the updated version of this
 
I need an updated version.
 
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

NICE,
 
Really appreciate you sharing this EA! It’s been such a great brainstorm for all of us who’re into strategy research.
 
I’ve spent days tweaking it over and over. Even my AI kept warning me not to use grid trading, saying it’ll eventually blow up the account and wipe out everything — that’s just how grid strategies work.
 
After plenty of backtesting, live forward testing and continuous adjustments, I’ve fine-tuned the lot sizing rules, factored in broker limits and solid money management. Finally I feel like I’m heading in the right direction.
 
Lately I’ve noticed many brokers keep changing leverage settings. I guess they’ve caught on that folks are consistently profiting here. We’d better move fast!
 
Thanks again so much for sharing!