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

Calculate ATR in multiple timeframes from one timeframe?

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

    Calculate ATR in multiple timeframes from one timeframe?

    If I add 1 minute data series for a number of FX instruments, how can I calculate the ATR of any timeframe that is an increment of 1 minute using the ATR values from the 1 minute data series within a strategy? Clearly, that increment could be any minute value greater than 1. I will not add data series at the specific timeframes as that would be an enormous overhead.

    Thanks.
    Last edited by jeronymite; 07-24-2016, 11:44 PM. Reason: Clarification
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hi jeronymite,

    To clarify, you are asking how to call an indicator using the input series of a secondary series is this correct?

    Code:
    In Initialize():
    Add(PeriodType.Minute, 1); <-- secondary series
    
    in OnBarUpdate():
    Print(ATR(BarsArray[1], 14)[0]);
    
    OR
    in #region Variables
    private ATR myATR;
    
    In OnStartUp():
    myATR = ATR(BarsArray[1], 14);
    
    In OnBarUpdate():
    Print(myATR[0]);
    Last edited by NinjaTrader_ChelseaB; 07-25-2016, 08:14 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Calculate ATR in multiple timeframes from one timeframe?

      I add a data series in Initialize, e.g. Add("$EURUSD",PeriodType.Minute,1) ;

      I can then get the ATR of that data series, e.g. ATR(BarsArray[1],14)[0]. This would be the ATR of a 1 minute timeframe.

      I want to use the 1 minute data series to calculate the ATR value for a timeframe of any length (in whole minutes) as if the data series were that larger timeframe. For example, use the 1 minute data series to calculate the ATR for the equivalent 5 minute data series of the same instrument. The result should be the same as if I had added a 5 minute data series and got the ATR from it.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        The ATR is not written in a way to do that.

        Make a copy of the ATR indicator, create a second input that is the size of the minutes.

        Then change the logic and calculations of the ATR to use the number of minutes from the input.

        I would not be able to assist creating this logic, however, this thread will remain open for any community members that would like to assist.

        You can also contact one of our professional NinjaScript Consultants who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Calculate ATR in multiple timeframes from one timeframe?

          Thanks, Chelsea. However, that approach is exactly what I need to avoid. The timeframe for the calculation of the ATR is dynamic. I cannot add data series to catch all possible values. I need to be able to derive the ATR of any given period of minutes from a single "base" ATR, or by some other means from a single "base" 1 minute timeframe.

          I am able to do the programming, but I am seeking advice on how this can be done.

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment


            #6
            Hello jeronymite,

            I am not suggesting that you add every data series. Please see post #4. I have suggested that you remake the ATR to have an input that is the number of minutes. The ATR would then aggregate the number of individual 1 minute bars and recalculate the ATR dynamically (using only 1 minute data as the input series).

            Using the existing ATR indicator that is built into NinjaTrader, I am not aware of a way to achieve your goal (of not adding 5 a minute series to the script though you want a calculation of the ATR with 5 minute bars as the input source).
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Calculate ATR in multiple timeframes from one timeframe?

              Thanks, Chelsea. Yes, I see I misunderstood your point in post #4 -- my apologies.

              Currently, your suggestion is exactly what I do. It's the overhead of that I had hoped to avoid. I'll keep looking at ways to improve the logic.

              Thanks.
              Multi-Dimensional Managed Trading
              jeronymite
              NinjaTrader Ecosystem Vendor - Mizpah Software

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by samish18, 04-17-2024, 08:57 AM
              16 responses
              55 views
              0 likes
              Last Post samish18  
              Started by arvidvanstaey, Today, 02:19 PM
              3 responses
              10 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by jordanq2, Today, 03:10 PM
              2 responses
              8 views
              0 likes
              Last Post jordanq2  
              Started by traderqz, Today, 12:06 AM
              10 responses
              18 views
              0 likes
              Last Post traderqz  
              Started by algospoke, 04-17-2024, 06:40 PM
              5 responses
              47 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X