Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicators decimal places on chart vs code

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

    Indicators decimal places on chart vs code

    Hi devs,

    When I add an indicator like the ATR to the chart, its value is displayed with 2 decimal places. However, when I read its values from within a strategy, the number of decimal places is greater, and there are instances where the values shown on the chart and in the code can differ. For example, on the chart, I might see an ATR of 10.00, while the code reads 9.999456392. I would like to know what rounding method the chart uses to display 2 decimal places so that I can apply the same method when reading values from within a strategy.

    I appreciate your assistance.

    #2
    Hello Quanto,

    While I cannot provide the internal code of the NinjaTrader Desktop platform, I can point you to the Microsoft Documentation on how to round values to any specific amount of decimal places.


    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your answer Chelsea,

      I understand that you cannot provide me with NinjaTrader's internal code, but there are four alternatives I could use according to your response:
      1. Round(ATR[x], 2);
      2. Round(ATR[x], 2, MidpointRounding.AwayFromZero);
      3. Round(ATR[x], 2, MidpointRounding.ToEven);
      4. Round(ATR[x], 2, MidpointRounding.ToZero);
      Which of the four could I use to get a result as close as possible to what I see in the ATR indicator on the chart?

      Comment


        #4
        Hello Quanto,

        Round(ATR[x], 2) is most likely the same or similar to what is being used for the rounding on plot values.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X