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

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.
    Kate W.NinjaTrader Customer Service

    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 ScottW, Today, 06:09 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by ScottWalsh, Today, 06:52 PM
      0 responses
      4 views
      0 likes
      Last Post ScottWalsh  
      Started by ftsc2022, 10-25-2022, 12:03 PM
      5 responses
      256 views
      0 likes
      Last Post KeyonMatthews  
      Started by Board game geek, 10-29-2023, 12:00 PM
      14 responses
      244 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Waxavi, 04-19-2024, 02:10 AM
      4 responses
      56 views
      0 likes
      Last Post sonia0101  
      Working...
      X