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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        597 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
        555 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X