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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      157 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      91 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      143 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      131 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X