Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculate int

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

    Calculate int

    Hello,

    I need to modify a 3rd party code. I simply want to have instead the Math.Abs the difference between the orderprice and the double price.

    It is working and gives me values with
    ATRdistShort = (int)Math.Round(Math.Abs(order.LimitPrice-price)/TickSize);
    ATRdistLong = (int)Math.Round(Math.Abs(price-order.LimitPrice)/TickSize);
    but of course its the Math.Abs.

    I need the "+" and the "-" and when I change it to
    ATRdistShort = (int)Math.Round((order.LimitPrice-price)/TickSize);
    ATRdistLong = (int)Math.Round((price-order.LimitPrice)/TickSize);
    then both show 0.

    When I use instead of "Math.Abs" eg "Math.Max" as I would do in MS-Excel or MS-Access then I get an error-message when compiling with arguments.

    What should I modify from the working lines please to have "+" int and "-" int from calculation.

    Thank you!
    Tony

    #2
    Hello tonynt,

    Thank you for your post.

    I was able to remove the Math.Abs and got the positive and negative values, not zero. I would suggest adding some prints to your code to figure out what the values for these are evaluating to right before this code gets executed.

    This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.



    If you run into issues like we saw here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess what is different between the two.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Hello Kate,

      thank you for your reply. You´re right, I got it also in the meantime. The reason for 0 was that I had the limits already in the chart but I have to add them after F5 the indicator so that its recognized.

      Best regards
      Tony

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      577 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X