Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

truncating/ rounding after 4,5 decimals

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

    truncating/ rounding after 4,5 decimals

    // Prints the highest high value over the last 20 periods
    double value = MAX(High, 20)[0];
    Print("The current MAX value is " + value.ToString());

    The above code gives the output as a lot of numbers following the decimal
    How do I truncate / round the values to the nearest 4,5 decimal


    #2
    I think the following code should give me the value in 4 decimals

    // Prints the highest high value over the last 20 periods
    double value = MAX(High, 20)[0];
    Print("The current MAX value is " + Math.round(value,4).ToString());



    Funny huh...My question and I am answering it myself
    I shall have to wait for Sunday afternoon to try it out live when market opens

    Comment


      #3
      Hello rjngh2005,

      Yes, Math.Round is what you need for this.
      Rounds a value to the nearest integer or to the specified number of fractional digits.
      Ryan M.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      55 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      35 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      103 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      183 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      171 views
      0 likes
      Last Post CarlTrading  
      Working...
      X