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

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 AaronKoRn, Yesterday, 09:49 PM
    0 responses
    11 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    10 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    11 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,981 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Yesterday, 06:48 PM
    0 responses
    9 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X