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 rtwave, 04-12-2024, 09:30 AM
                4 responses
                31 views
                0 likes
                Last Post rtwave
                by rtwave
                 
                Started by yertle, Yesterday, 08:38 AM
                7 responses
                29 views
                0 likes
                Last Post yertle
                by yertle
                 
                Started by bmartz, 03-12-2024, 06:12 AM
                2 responses
                22 views
                0 likes
                Last Post bmartz
                by bmartz
                 
                Started by funk10101, Today, 12:02 AM
                0 responses
                7 views
                0 likes
                Last Post funk10101  
                Started by gravdigaz6, Yesterday, 11:40 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X