Error Martingale

 
Error, martingale calculation.

the doubling of the lot in the martinagale strategy proves to be inconsistent.

It jumps from 0.1 to 0.2 to 1.6, after the take it goes back to 0.1 and then jumps to 0.8.

Which part of the code could be the problem?


//+------------------------------------------------------------------+
//| Function to calculate the lot size with Martingale               |
//+------------------------------------------------------------------+
double CalculateLotSize()
{
    double lotSize = BaseLotSize;

    if (UseMartingale)
    {
        lotSize = BaseLotSize * MathPow(MartingaleMultiplier, Martingale_CurrentLevel);

        // Cap the lot size to the maximum allowed
        if (lotSize > MaxLotSize)
        {
            lotSize = MaxLotSize;
        }
    }

    Print("DEBUG: Calculated Lot Size: ", lotSize, 
          ", at Martingale Level: ", Martingale_CurrentLevel);
    return NormalizeDouble(lotSize, 2); // Normalize to two decimal places
}