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 Perr0Grande, Today, 08:16 PM
                0 responses
                1 view
                0 likes
                Last Post Perr0Grande  
                Started by elderan, Today, 08:03 PM
                0 responses
                3 views
                0 likes
                Last Post elderan
                by elderan
                 
                Started by algospoke, Today, 06:40 PM
                0 responses
                10 views
                0 likes
                Last Post algospoke  
                Started by maybeimnotrader, Today, 05:46 PM
                0 responses
                9 views
                0 likes
                Last Post maybeimnotrader  
                Started by quantismo, Today, 05:13 PM
                0 responses
                7 views
                0 likes
                Last Post quantismo  
                Working...
                X