Bulletproof Lotsizing based on ATR Stoploss

 

So it seems that that 'classic' way to calculate ATR stoploss can fall apart depending on the brokers configuration for a <symbol>

double CalcLots(double PctEquityX, double SlDistanceX){
      double ticksize = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE); //<-- Smallest px increment possible for <symbol> 
      double tickvalue = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE); //<-- Value of smallest px change (0.1 GBP indeed each tick is worth 10p!)
      double lotstep = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP); //<-- The minimum volume step for <symbol>
      Print(ticksize,"<--ticksize",tickvalue,"<--tickvalue GBP ",lotstep,"<--lotstep"); 
      
      if(ticksize == 0 || tickvalue == 0|| lotstep == 0){ 
      Print(__FUNCTION__, "Lot size cannot be calculated");
      return 0;
      }
      
      double TradeMoney = AccountInfoDouble(ACCOUNT_EQUITY) * (PctEquityX * 0.01); //<-- Equity to be used for a single trade
      double LossMoneyPerLotStep = (SlDistanceX/ticksize) * tickvalue * lotstep; //<-- 1.5ATR = 0.00375/0.00001 375 points; 375 points * 0.1GBP = £37.5 loss (if 1 lot); x minStep of 0.1 = £3.75 max loss at 1.5ATR if trading 0.1 lot
      double CalcdLots = MathFloor(TradeMoney / LossMoneyPerLotStep * lotstep); //<-- £1000 / £3.75 * 0.1
      double MaxLoss = (CalcdLots * SlDistanceX * tickvalue);
      Print(NormalizeDouble(TradeMoney,_Digits)," of equity used for trade");
      Print(NormalizeDouble(LossMoneyPerLotStep,_Digits)," max loss if trading minimum lot increment");
      Print(NormalizeDouble(CalcdLots,_Digits)," lots used for the trade");
      return CalcdLots; //<-- For some reason this returns 10x what I am looking for on PS and nothing on OA MT5 so have 
      
}

For Example here's what happens with the above code on Pepperstone MT5 vs Oanda MT5 when trading 1% equity on 100000GBP demo account:




Even though the code above always prints '<~1000> of equity used for trade' this does not seem to be respected.
Each broker platform is slightly different (CFD's are the wild west!) but has anyone found a solution for sanity-checking lot size prior to placing the order?
i.e. TradeMoney is 1000, (CalcdLots is 26 * ATR distance etc.) = 10000 ... thats too much!
At the moment I am thinking of defining tradeable symbols and their custom Volume Divisors but that.

Any thoughts would be appreciated!