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 cmoran13, 04-16-2026, 01:02 PM
        0 responses
        43 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        158 views
        2 likes
        Last Post CaptainJack  
        Working...
        X