NormalizeVolumeInUnits() - wrong value for XTIUSD

Created at 18 Jul 2022, 11:18
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MA

marktbs

Joined 18.07.2022

NormalizeVolumeInUnits() - wrong value for XTIUSD
18 Jul 2022, 11:18


When I try to use method NormalizeVolumeInUnits() for XTIUSD I'm getting correct values for forex pairs, but wrong value for XTIUSD. See example method and results:

        private void OpenPosition()
        {
            // Initialize
            TradeType TradeDirection;
            double OrderVolume;
            double Normalized1;
            double Normalized2;

            //// Open Position
            if (Trader.CurrentPosition == null)
            {

                if (TradeLogic(true, out buy))
                {
                    if (buy)
                    {
                        TradeDirection = TradeType.Buy;
                        RequestedPrice = Symbol.Bid;
                    }
                    else
                    {
                        TradeDirection = TradeType.Sell;
                        RequestedPrice = Symbol.Ask;
                    }

                    //// Account.Balance = 1000, Profile.TradingMargin_int = 20, Leverage = 100
                    OrderVolume = (Account.Balance * Profile.TradingMargin_int / 100) * Leverage ;
                    
                    //// Normalization 1 (GOOD)
                    Normalized1 = OrderVolume % 1000 >= 500 ? OrderVolume + 1000 - OrderVolume % 1000 : OrderVolume - OrderVolume % 1000; // Normalize volume

                    //// Normalization 2 (BAD)
                    Normalized2 = Symbol.NormalizeVolumeInUnits(OrderVolume));
                }

            }
        }

Results:

Normalized1 = 20'000 (ok, approx. 20'000 GBP margin)

Normalized2 = 5'000 (wrong)

 

Am I missing something?

 


@marktbs