Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rounding not working as it should

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

    Rounding not working as it should

    Hello,

    In my script if have a simple formula:
    Var C = (Var A / Var B)

    Typically, the result of Var C will be a number like "2.325...."

    I want to round it up to a whole number, in this case "3". To do this I have tried Math.Ceiling() but when the number is printed onto the output, it rounds down to "2". What method should I use to round up to the next whole number?

    #2
    Hello Don22Trader1,

    While this would fall under general C# that is not specific to NinjaScript, I would expect Math.Ceiling() to be correct.

    I gave this a test and I am not able to reproduce.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Don22Trader1 This can sometimes happen if the variables include an integer type of variable in the statement. Check that all variables are real types. If that's all good, you may want to provide just the relevant code for review here, to see if anything can be spotted by NT Support or other Forum members.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      89 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      152 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      80 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      53 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      63 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X