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 zstheorist, Today, 07:52 PM
                0 responses
                7 views
                0 likes
                Last Post zstheorist  
                Started by pmachiraju, 11-01-2023, 04:46 AM
                8 responses
                150 views
                0 likes
                Last Post rehmans
                by rehmans
                 
                Started by mattbsea, Today, 05:44 PM
                0 responses
                6 views
                0 likes
                Last Post mattbsea  
                Started by RideMe, 04-07-2024, 04:54 PM
                6 responses
                33 views
                0 likes
                Last Post RideMe
                by RideMe
                 
                Started by tkaboris, Today, 05:13 PM
                0 responses
                6 views
                0 likes
                Last Post tkaboris  
                Working...
                X