Experts: Semi-HFT Grid Bot Two-sided seed-bump-martingale grid with basket take profit

Semi-HFT Grid Bot Two-sided seed-bump-martingale grid with basket take profit:

A two-sided grid EA that lays a small symmetric ladder of pending stop orders around the current price, then escalates in two stages as fills accumulate: first a single opposite-side lot "bump," then a full martingale doubling sequence with two extra grid levels added. The whole basket is watched as one unit and closed the moment its combined floating profit reaches a target, after which a fresh grid re-arms automatically. Built with separate, auto-selected input profiles for XAUUSD and NAS100/US100, since the two symbols need very different lot sizes, grid spacing, and broker minimum-distance handling.

Semi-HFT Grid Bot  Two-sided seed-bump-martingale grid with basket take profit

Author: Muhammad Wasim

The following are the defects i've seen in the strategy initially :

  1. Deadlock: once both sides are full, net exposure is zero and no orders remain. The basket can never reach TP, and with the stop off it sits at about −$337 indefinitely, paying swap.
  2. Levels tracked by order comment: many brokers rewrite or truncate comments. The EA then sees the level as missing and places a duplicate every tick.
  3. Basket close has no retry or price refresh: a requote leaves orphan positions, and the EA then seeds a new grid on top of them.
  4. Replace places even if the delete failed: if the pending order had just triggered, the level is doubled.
  5. Restart recovery is fragile: the base is rebuilt from L1's open price, which is wrong if L1 was market-filled or the step changed.
  6. Step is in raw points: on a 3-digit gold feed, 50 points is $0.05, which is inside the spread.
  7. Spread filter only applies at seed time: there is no session or news guard and no equity protection.

i will write a resolver to these points and give you my feedback then .

Solutour Limitied #:

The following are the defects i've seen in the strategy initially :

  1. Deadlock: once both sides are full, net exposure is zero and no orders remain. The basket can never reach TP, and with the stop off it sits at about −$337 indefinitely, paying swap.
  2. Levels tracked by order comment: many brokers rewrite or truncate comments. The EA then sees the level as missing and places a duplicate every tick.
  3. Basket close has no retry or price refresh: a requote leaves orphan positions, and the EA then seeds a new grid on top of them.
  4. Replace places even if the delete failed: if the pending order had just triggered, the level is doubled.
  5. Restart recovery is fragile: the base is rebuilt from L1's open price, which is wrong if L1 was market-filled or the step changed.
  6. Step is in raw points: on a 3-digit gold feed, 50 points is $0.05, which is inside the spread.
  7. Spread filter only applies at seed time: there is no session or news guard and no equity protection.

i will write a resolver to these points and give you my feedback then .

Solutour Limitied .
Thanks for Highlighting the points . I Appreciate Your Effort and very will thankful if it resolves with your Experience .

Sorry to disappoint you Muhammed , i tried to changes but it did not work with me as the issue is the main idea of doubling itself :

in the attached file  SemiHFT_GridBot.mq4) , the strategy itself was unchanged but i did unchanged:

  • Levels identified by magic number, not order comment.
  • Basket close retries until flat before re-seeding.
  • A pending level is re-placed only if its delete succeeded.
  • Base price saved across restarts.

Another Variant is SemiHFT_GridBot_Unlock.mq4 where i added more :

  • Exact-flat order when the grid locks.
  • Trend-unlock breakout legs, capped at four attempts, then hold and alert.
  • Step sized from spread and ATR.
  • 60-second pause after a rejected order.
  • Session filter and close-on-lock.

Risks mitigated, and how

Risk Mitigation Outcome
Duplicate or orphaned orders The four replica fixes Addressed (code review only; a tester cannot trigger these)
Locked book left 0.04 lots unbalanced Exact-flat order Fixed; removed the largest loss in the first test
Rejected order re-sent every tick 60-second pause Fixed
Grid locks with no exit Trend unlock, session filter, close on lock Not solved; every variant lost money
Swap drain on a held book None without closing Not solved

End result 

  • 1st version , one year on $3,000: stopped out in 24 days (−99.6%).
  • Four-week windows: Code and session filter −21% to −29%; trend unlock −63% to over −100%; close on lock −94% to −101%.
  • Cause: 2% to 7% of baskets lock, against a break-even of about 0.65% ($2.30 win, $351 lock). Exit rules cannot fix that; the entry design ($0.50 step, $0.38 spread, five doubling levels) is the problem.
so either to change the strategy itself , or find away around the loss point (sorry but i can think of awork around to this),