Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Convert Lots from int to double

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Convert Lots from int to double

    I want to trade at 0.1 lots in my strategy but "Lots" is set to be an int. If I change it to a double then the strategy will not compile. It seems as thought Lots can only be an integer. How thereofre do I trade at less than 1 lot.

    Please help,

    Thanks

    Nigel.

    #2
    How are you converting it? if done properly it should compile, unless it is trashing a later reference? Can we see some code?

    Comment


      #3
      Nigel, where is lots set to an integer value? If it is an input that you chose, you can just go back and re-do it as a double or decimal. Just as Sleeping Troll said, can we see some code? We'll be able to help you much better if we can see the code.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Convert Lots from int to double

        here is the relevant part of the code:-

        #region Variables
        // Wizard generated variables
        private double lots = 1.0; // Default setting for Lots


        if (ToTime(Time[0]) > 80005 && ToTime(Time[0]) <= 160000 && tradeno == 0)
        {
        EnterShort(Lots, "LondonShort");
        tradeno = tradeno + 1;
        }


        #region Properties
        [Description("Lots")]
        [Category("Parameters")]
        public double Lots
        {
        get { return lots; }
        set { lots = Math.Max(1.0, value); }
        //set { lots = Math.Round(1, value); }
        }


        Mnay thanks,

        Nigel

        Comment


          #5
          Nigel, please don't start multiple threads on the same issue - I'll respond to your other one in a few, thanks.

          Comment


            #6
            #region Properties
            [Description("Lots")]
            [Category("Parameters")]
            public double Lots
            {
            get { return lots; }
            set { lots = Math.Max(0, value); }
            }

            should do it this picks the max of "0" and "Value" rather than the max of " 1 " and value. this sets the minimum for the value.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            574 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X