• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by pmmkm, Today, 04:14 AM
    0 responses
    1 view
    0 likes
    Last Post pmmkm
    by pmmkm
     
    Started by zachiatrist, 12-05-2019, 07:11 AM
    4 responses
    26 views
    0 likes
    Last Post pmmkm
    by pmmkm
     
    Started by jgfirefn, Today, 02:26 AM
    0 responses
    2 views
    0 likes
    Last Post jgfirefn  
    Started by Gerik, Yesterday, 10:58 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by Gerik, Yesterday, 11:27 PM
    0 responses
    4 views
    0 likes
    Last Post Gerik
    by Gerik
     
    Working...
    X