Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rounding decimal number

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

    Rounding decimal number

    I have a small question.
    I want to convert a double type to an int type.
    I must first make a rounding operation on the double.

    the double type that I want to round to zero decimal places is as follows:

    ATR (Close, 14) [0] * 100

    sorry but I can not find the function that makes this operation

    thanks to all

    #2
    Hello Picita,

    You can cast a variable as a different type by placing in parentheses like this:

    int myInt = (int) ATR(14)[0] * 100;

    More control is available with C# System.Math for the rounding, but you will still need to cast it as an integer.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by Picita View Post
      I have a small question.
      I want to convert a double type to an int type.
      I must first make a rounding operation on the double.

      the double type that I want to round to zero decimal places is as follows:

      ATR (Close, 14) [0] * 100

      sorry but I can not find the function that makes this operation

      thanks to all
      ok

      I found the math functions in C # here:

      Provides constants and static methods for trigonometric, logarithmic, and other common mathematical functions.


      thank you very much

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      574 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      332 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X