Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 tkaboris, Today, 05:13 PM
      0 responses
      2 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,281 views
      0 likes
      Last Post Leafcutter  
      Started by WHICKED, Today, 12:45 PM
      2 responses
      19 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by Tim-c, Today, 02:10 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Taddypole, Today, 02:47 PM
      0 responses
      5 views
      0 likes
      Last Post Taddypole  
      Working...
      X