Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATR percent

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

    ATR percent

    Hello in new at ninja trader programming,
    I'm trying to develop an indicator it will be ATR%= ATR/close[0] , so I thought it will be very easy just editing the ATR

    protected override void OnBarUpdate()
    {
    if (CurrentBar == 0)
    Value.Set(High[0] - Low[0]);
    else
    {
    double trueRange = High[0] - Low[0];
    trueRange = Math.Max(Math.Abs(Low[0] - Close[1]), Math.Max(trueRange, Math.Abs(High[0] - Close[1])));
    double calc = ((Math.Min(CurrentBar + 1, Period) - 1 ) * Value[1] + trueRange) / Math.Min(CurrentBar + 1, Period);
    Value.Set(calc/Close[0]);

    }
    }

    but it doesn't work , the result is a crazy number

    so decide to try any onther operacion like Value.Set(calc/2); Value.Set(calc*2); Value.Set(calc+1);and nothing works it continues returning random numbers...


    please help thanks

    #2
    Hello gacd9999,

    Thanks for your post and welcome to the NinjaTrader forums!

    The ATR will will calculate the range of a bar and will be averaged over the period chosen.

    Using the ES 06-16 as an example and an ATR of period 14 and 5 minute bars, today, you would see something like an ATR of 1.5 points while the current price value is in the area of 2067. Dividing the ATR by the close price would indeed yield a number of no meaning.

    What I think you are wanting to do is to see if the current bars range is X% of the current ATR. If my understanding is correct then one way to help you see how to (using the standard ATR) do this would be to plot two ATRs, One with a period of 1 and the other with whatever period you want to examine (14 is the default). The ATR with a period of 1 will show the true range of each bar, perhaps this is all you will need. I have attached an example with the two ATRs (1) and (14). I've changed the ATR(1) to show as a bar type and put both ATRs in the same panel.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    557 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 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
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X