Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Rounding question

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

    Rounding question

    Is it a way to round a value for a ray so it plots at the nearest 10? I don't know where to start here. Would be great with some help on this. example below:

    MidLine.Set(High[0] + Low[0] + Close[0] /3);

    DrawRay("Midline", 10, Midline Rounded to nearest 10, 0, Midline Rounded to nearest 10, Color.LimeGreen);

    Regards, FinnBjurvoll

    #2
    Hello,

    Is this 10 is it the tick size of the instrument your using this on or just a number your wanting to round too?

    I look forward to assisting you further.

    Comment


      #3
      Thanks for quick reply. What I would like to do here is this:

      Lets say having this line plottet on the 6E, I get my pivot from the last 1 hour period. The H+L+C/3 ends up at a value of 1.3444. I would like to round that value down and plot the line at 1.3440. If it ended up above 45 it should be rounded to 1.3450.

      regards
      FinnBjurvoll

      Comment


        #4
        Hello,

        There is a function to rout it to tick size but this will not work in your case. What you will need to do in this case is due this rounding manually.

        Suggest you google rounding in C# for more information on how to do this in c# programming.

        Let me know if I can be of further assistance.

        Comment


          #5
          How about Math.Round(H+L+C/3, 3)

          Comment


            #6
            Rounding

            Thanks alot Brett and Baruch. I tried your suggestion Baruch, but it did not what I wanted it to. Will look closer into this later. Thanks for your help.

            Regards, FinnBjurvoll

            Comment


              #7
              Originally posted by finnbjurvoll View Post
              Thanks for quick reply. What I would like to do here is this:

              Lets say having this line plottet on the 6E, I get my pivot from the last 1 hour period. The H+L+C/3 ends up at a value of 1.3444. I would like to round that value down and plot the line at 1.3440. If it ended up above 45 it should be rounded to 1.3450.

              regards
              FinnBjurvoll
              Math.Round(var, 3, MidpointRounding.AwayFromZero);

              where "var" is the variable that you are rounding.

              Comment


                #8
                Koganam, that worked perfect! Thank you so much for your help.
                Regards, FinnBjurvoll

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Felix Reichert, Today, 02:12 PM
                0 responses
                1 view
                0 likes
                Last Post Felix Reichert  
                Started by Tim-c, Today, 02:10 PM
                0 responses
                1 view
                0 likes
                Last Post Tim-c
                by Tim-c
                 
                Started by cre8able, Today, 01:16 PM
                2 responses
                9 views
                0 likes
                Last Post cre8able  
                Started by chbruno, 04-24-2024, 04:10 PM
                3 responses
                48 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by samish18, Today, 01:01 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Working...
                X