so far, I did use this formula without question.
stoploss = NormalizeDouble(Ask - StopLossInPoint * Point, Digits);
But today's sudden price spike made me think about it again. I guessed Ask price(XAUUSD, 2023.11.14 GMT+2 15:30) was unreasonably big at that moment. Because my log message says that the stoploss(300point based) computed with above formula was even bigger than the chart-displayed price level(I hope it's Bid price what I see in chart), whereas it should be smaller than it.
Long Order Failed with error #130, which means invalid stop loss.
So I think the spread was approached 300 point, and failed to open position.
Can I use Bid for computing stop loss of buy position like this?
stoploss = NormalizeDouble(Bid - StopLossInPoint * Point, Digits);
What could using Bid make unexpected result?
some sites requires to use Bid.
https://www.earnforex.com/guides/ordersend-error-130/
I inspected open sources in github, and many of them is based on Ask.
imho for BUY orders You should use
double sl = NormalizeDouble(symbolInfo.Bid() - StopLevel * point, (int)digits);
and for SELL orders You should use
double sl = NormalizeDouble(symbolInfo.Ask() + StopLevel * point, (int)digits);
-it is from my mql5 but it is almost the same in older
and the same thing is suggested on this website that You posted link to.