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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      89 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X