Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rounding confusion

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

    Rounding confusion

    Here is an indicator I created to use as a volatility reference;
    Up.Set(Close[0]+ATR(1)[0]);
    I use it on a 2 minute chart and it priduces outputs that are even with the tick, ie, 1025.00, 1025.25, 1025.50, etc.

    I have another indicator which does not produce an output which is even with the tick, ie, 1025.888, 1025.092, etc. For this indicator, I enclosed the formula in Math.Round, which fixed the problem. To be consistent, I also used the Math.Round() in the above indicator incase it ever produced an uneven number that might be ignored by my strategy when placing stops. The indicator now looks like this;

    Up.Set(Math.Round(Close[
    0]+ATR(MyInput0)[0]));

    This changed the output, as if it was rounding twice. I realize I can just remove the Math.Round(), but I am trying to understand what is happening, as I'm creating a strategy to use this indicator for setting stops and don't want it to be ignored by the strategy if uneven numbers ever exist. Can anyone please explain this or offer some advice?

    Thank you.

    Safetrading


    #2
    Not sure what you mean exactly, but to round to ticksize you should use this: http://www.ninjatrader-support.com/H...2TickSize.html
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      safetrading,

      It could be your formula.

      try breaking the formula down to just what you want.

      Original

      Up.Set(Math.Round(Close[0]+ATR(MyInput0)[0]));
      ---------------------------------------------------------

      round just Close[0]


      Up.Set((Math.Round(Close[0])+ATR(MyInput0)[0]));
      --------------------------------------------------------

      round just ATR...

      Up.Set((Close[0])+ Math.Round(ATR(MyInput0)[0]));
      ------------------------------------------------------------

      round both seperately.

      Up.Set((Math.Round(Close[0])+ Math.Round(ATR(MyInput0)[0])));

      --------------------------------------------------------------

      RJay
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        Thanks

        Thanks, I'll give it a try. I appreciate your time.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        161 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        308 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        245 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        349 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X