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