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

Daily ATR

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

    Daily ATR

    Hi, so I need to access the ATR for the last 5 days in my indicator that will run on a 1 minute chart. I added the statement below but it seems to only execute once a day. I need it to run more than that in case I run the indicator mid day.

    Also, I only want the daily ATR calculated during regular trading hours although my indicator needs to run for a 24/7 session.

    Any thoughts? thanks!

    Add(PeriodType.Day, 1);

    #2
    Hello,

    Thank you for the question.

    For this you will need to utilize the BarsInProgress index for the added series and also ensure that you have enough days loaded in the chart. The Add() will add a day series with the amount of days you have selected to load.

    You could use something like the following:

    Code:
    if(BarsInProgress == 1)
    {
    	double atrValue = ATR(Closes[1], 12)[0];	
    	Print(Times[1] + " " + atrValue);
    }
    This first checks if the bar that is currently being processed is from the Day series that was added or index 1.
    Next I have assigned a double variable named atrValue the value from the ATR using the Closes[1] or the daily closes. you need to make sure to use Closes, Opens, Highs, Lows instead of Close, Open, High, or Low when you are using multiple series. This allows you to pick which series the data is coming from.

    For the time constraint, the overall indicator will use the session template of the chart.
    if you have a 24 hour session selected the indicator can run 24 hours. You can add time constraints around portions of code using the Time options. Here is an example:

    Code:
    if(Time[0] >= ToTime(9,0,0) && Time[0] <= ToTime(16, 30,0))
    {
    
    }
    This would only allow the code in between the braces to run when the 1 minute or chart series bar time is between the hours of 9am and 4:30pm

    Here are some helpful helpguide links:






    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      The indicator that you can download here



      comes with an integrated daily range calculations. You can use it to display the average daily range (ADR = SMA of session range) over the last 5 days. The session range can be displayed for the full session or the regular session.

      Please do not use the session template 24/7, as there is no trading instrument in the world for which it reflects the contractual trading times.

      The indicator attached displays the average daily range for ES 12-14 for the regular session. The ADR(5) for ES 12-14 iss 11 points, while the ADR(10) is 11.75 points. This shows that the volatility declined during the last week.

      The average daily range is added to the current low and is subtracted from the current high. This makes up for a daily target based on the volatility of the prior 5 and 10 days.
      Attached Files

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Sparkyboy, Today, 10:57 AM
      0 responses
      1 view
      0 likes
      Last Post Sparkyboy  
      Started by TheMarlin801, 10-13-2020, 01:40 AM
      21 responses
      3,917 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by timmbbo, 07-05-2023, 10:21 PM
      3 responses
      152 views
      0 likes
      Last Post grayfrog  
      Started by Lumbeezl, 01-11-2022, 06:50 PM
      30 responses
      810 views
      1 like
      Last Post grayfrog  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X