Forex_Strategy_Builder.Backtester.NormalizeEntryLots C# (CSharp) Method

NormalizeEntryLots() static private method

static private NormalizeEntryLots ( double lots ) : double
lots double
return double
        static double NormalizeEntryLots(double lots)
        {
            double minlot  = 0.01;
            double maxlot  = Strategy.MaxOpenLots;
            double lotstep = 0.01;

            if (lots <= 0)
                return (0);

            int steps = (int)Math.Round((lots - minlot) / lotstep);
            lots = minlot + steps * lotstep;

            if (lots <= minlot)
                return (minlot);

            if (lots >= maxlot)
                return (maxlot);

            return lots;
        }