Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Converting double to Int to use as calculation of share quantity

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

    Converting double to Int to use as calculation of share quantity

    I know that C# has a conversion process that is something like this:

    double shareCalc = Math.Floor(unitSize / ((resistance1 - Support1) * winningPercentage));

    int shareQuantity = Convert.ToInt32(shareCalc);


    so that i can use my double value as an int for the purpose of determining and entering share quantity in my order code.


    I keep getting this message:

    **NT** Error on calling 'OnBarUpdate' method for strategy 'BasicPivot/13eb629f4d0544df810a5ccff04f6238': Value was either too large or too small for an Int32.

    Please advise, and thanks in advance.

    Regards,

    Andrew

    #2
    Hello,

    Thanks for the note.

    Can you please try Print(shareCalc); before you try to convert it to an Int so we can take a look at what price we are trying to convert to int.

    It may be we need to use Math.Round() to round the value down so it can be converted.

    -Brett

    Comment


      #3
      Here is an interesting piece of code printout...hmmm...

      590
      Infinity
      Last edited by NinjaTrader_Brett; 08-23-2012, 07:19 AM.

      Comment


        #4
        Hello,

        Looks like your math action is causing an infinity output which then wont convert to Int.

        Would need to have you check your math there and see what is going wrong.

        -Brett

        Comment


          #5
          I would like to send you a code snippet privately, may i?

          Comment


            #6
            Hello,

            Yes you can to support at ninjatrader dot com ATTN: Brett. I can take a quick look although I cannot do debugging unfortunately though I can take a quick look to see if I can assist.

            -Brett

            Comment


              #7
              email has been sent

              Comment


                #8
                Thanks, I replied via email and will follow up there.

                -Brett

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Irukandji, Today, 05:50 AM
                0 responses
                5 views
                0 likes
                Last Post Irukandji  
                Started by ageeholdings, Today, 05:22 AM
                0 responses
                8 views
                0 likes
                Last Post ageeholdings  
                Started by llanqui, 04-28-2024, 10:32 AM
                2 responses
                19 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by DroneBlackCa, Today, 05:17 AM
                0 responses
                6 views
                0 likes
                Last Post DroneBlackCa  
                Started by tradingnasdaqprueba, 04-09-2024, 09:52 AM
                7 responses
                50 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X