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

Calculations with ints

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

    Calculations with ints

    Hello,

    I have to ask about calculations with integers. I have changed in my indicator from eg if( Vol1[0]>Vol1[1]*1.05 to if( Vol1[0]>VOL1[1]*(1+(volbar1/100))) so that I can change the value "05" in the parameters and not in the code. But with if( Vol1[0]>VOL1[1]*(1+(volbar1/100))) I dont get correct results. What I am doing wrong here? Sorry if I have an issue on my end with maths.

    Thank you!
    Tony

    #2
    Hello tonynt,

    When you say the result is wrong, what specifically is happening vs what should the result be? That would help to isolate what part of the calculation is going to need changed.

    In what you provided you are using ints so if you mean the remainder is missing you may need to stop using ints and use doubles. That could be as simple as tagging a d at the end of the number or adding a remainder like 1.0:

    Code:
    (Vol1[0]>VOL1[1]*([B]1.0[/B]+(volbar1/[B]100d[/B]))
    https://docs.microsoft.com/en-us/dot...-numeric-types

    In the first syntax you provided you used *1.05 which is a double and 1 would be an int so that is a difference. You also added some additional code to the second syntax (1+(volbar1/100). You could likely make use of a print to see what values are actually being calculated to get an idea of what to do next:

    Code:
    Print(1+(volbar1/100));

    Please let me know if I may be of additional assistance.
    Last edited by NinjaTrader_Jesse; 01-19-2021, 08:24 AM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply. With doubles it works, bothering that I didnt think on that.

      Best regards
      Tony

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Lele2k24, Today, 01:32 PM
      4 responses
      7 views
      0 likes
      Last Post Lele2k24  
      Started by Sebastian - TwinPeaks, Today, 01:31 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by tonynt, Today, 01:48 PM
      1 response
      2 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by eladlevi, Today, 11:02 AM
      4 responses
      23 views
      0 likes
      Last Post eladlevi  
      Started by synthhokie, Today, 10:24 AM
      5 responses
      15 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X