Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rounding issue

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

    Rounding issue

    Hello,
    I'm attempting to round a number to the .001 so far it's being rounded to the .1. Can someone please look at this and offer a suggestion? Thanks

    Print("The current iClose is " + Math.Round(iclosevalue, 3).ToString());

    #2
    Hello CaptainAmericaXX,

    Everything looks to be correct.

    What value is iclosevalue at when you are getting these results?

    I want a rounding method on double values in C#. It needs to be able to round a double value to any rounding precision value. My code on hand looks like: public static double RoundI(double number,
    JCNinjaTrader Customer Service

    Comment


      #3
      Originally posted by CaptainAmericaXX View Post
      Hello,
      I'm attempting to round a number to the .001 so far it's being rounded to the .1. Can someone please look at this and offer a suggestion? Thanks

      Print("The current iClose is " + Math.Round(iclosevalue, 3).ToString());
      That depends on what values you are rounding in the first place. The precision of the displayed value is a different kettle of fish from the value.

      As an example, get a "Print" of the raw value too, and let us see if and where there might be a discrepancy,

      Comment


        #4
        JC, Koganam,
        Sure enough. The "iclosevalue" was based off of an indicator value and it would only round to the tenths, so 10.121345 to 10.1. I plugged 10.121345 into the iclosevalue and it the Math.Round(iclosevalue, 3) rounded it to 10.121. Why will the indicator not round to the thousandths?

        Comment


          #5
          Originally posted by CaptainAmericaXX View Post
          JC, Koganam,
          Sure enough. The "iclosevalue" was based off of an indicator value and it would only round to the tenths, so 10.121345 to 10.1. I plugged 10.121345 into the iclosevalue and it the Math.Round(iclosevalue, 3) rounded it to 10.121. Why will the indicator not round to the thousandths?
          That is a strange one. I actually have the opposite problem, where my indicator values are being returned to a meaningless 15 decimal places, so I always Round2TickSize for meaningful decision values.

          I cannot think of anything other than for you to track a value through its life in the code, to see where it may be being already rounded before it reaches where you are expecting to round the value.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          595 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          554 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X