Announcement

Collapse
No announcement yet.

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.

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