What 10016 actually means on the wire
TRADE_RETCODE_INVALID_STOPS is not a random outage. The requested SL or TP is closer to market than the broker allows, on the wrong side of Bid versus Ask, frozen because a pending is inside freeze level, or rounded to the wrong digits. Buys use Bid for stops below; sells use Ask for stops above. Ignoring that offset is the retail bug. Gold and indices print it constantly during spikes when STOPLEVEL expands.
Node-side retry with a growing buffer
activate Venasri free on your MT5 account if 10016 currently means you click modify five times by hand. Those extra clicks are also how you burn a 2,000-request cap.
Do not retry the same illegal price
Venasri Equity Guard is the backstop while retries run. The 3-second poll can flatten if the naked window lasts long enough for gold to travel 2% of equity. 10016 handling reduces that window. It does not replace the equity loop.
Normalize digits before you philosophize
EURUSD is 5 digits on most raw books, JPY pairs 3, gold 2 or 3 depending on the feed. NormalizeDouble(sl, digits) is not optional. A 1.084513 stop on a 5-digit symbol can also return 10016. Venasri normalizes, then applies STOPLEVEL, then retries. If it still fails after max retries, the cockpit shows the fail so you are not staring at a ticket you believe is protected.
If 10016 storms during news, you should have been in the 30-minute blackout. Fixing invalid stops is not permission to trade CPI with a 10-pip gold SL.