Announcement

Collapse
No announcement yet.

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.
    BrettNinjaTrader Product Management

    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.
        BrettNinjaTrader Product Management

        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 Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                571 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                330 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                548 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                549 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X