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 CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      58 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      34 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      197 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      362 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      282 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X