Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Math.Abs() not working correctly?

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

    Math.Abs() not working correctly?

    Are there any reports on Math.Abs not working correctly in NT7rc1?

    I looked in the F1 help but there is no definition of correct useage, and the strategy I am working on seems to have inconsistent behaviour (which is narrowed down to Math.Abs).

    Just asking, as I simplify the strategy prior to emailing to support.

    Jon

    #2
    Trader.Jon, I have not heard any reports of the absolute value function not working correctly. I just tested this out and everything is working as expected. Can you post the code you're using?

    This code:
    Code:
    protected override void OnBarUpdate()
    {
        if (CurrentBar == 0)
        {
            double positive = 3.14;
            double negative = -4.13;
            
            double abs_pos = Math.Abs(positive);
            double abs_neg = Math.Abs(negative);
            
            Print("abs_pos (should be 3.14): " + abs_pos);
            Print("abs_neg (should be 4.13): " + abs_neg);
        }
    }
    produces this output:
    Code:
    abs_pos (should be 3.14): 3.14
    abs_neg (should be 4.13): 4.13
    AustinNinjaTrader Customer Service

    Comment


      #3
      Austin,

      Thanks for the detailed response. I have a feeling, after seeing your post, that I am not using it correctly, but I am not getting any compile errors, or use errors in the logs either. Do I only use it with doubles?

      The strategy framework has restrictions on its use, but I can email it to your attention.

      I am also sending screen shot .

      Jon

      Comment


        #4
        Jon, I've replied to your email as well, but this function should not be giving you false answers. It is a very straight forward method, and you can feed it basically any data type you want and you will get the correct absolute value.
        AustinNinjaTrader Customer Service

        Comment


          #5
          The indicator I was using does a recalculate+repaint several bars back into past and was the cause of the annoyance ... or rather my use of that indicator was the cause of my annoyance. Thanks for the input!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          627 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          359 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          562 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          567 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X