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

Indicator based on a different time frame

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

    Indicator based on a different time frame

    Hi All,

    If I am running a strategy on a 5min chart and want to know what the current ATR value on a daily chart is, how would I code that?

    Usually if I want the value of a 10 period ATR on my 5min chart I just use: ATR(10)[0]

    How would I get the value for a 10 period ATR based on a daily bars (but from my strategy which uses a 5min chart)

    thanks.

    #2
    DarkPool, if your daily chart was added as second series (so first Add() ), then you could for example use -

    ATR(Closes[1], 10)[0];

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi,

      I cant seem to add the daily chart. I am using the following code in the initialize method:
      Add("ALSI 06-12", PeriodType.Day, 1);

      But then I get the following error:
      **NT** Error on calling 'OnBarUpdate' method for strategy 'bdStratORB/cde7632026994f50ac205ec8fba22009': Object reference not set to an instance of an object.

      Any ideas what could be wrong?

      Comment


        #4
        Do you work on ALSI 06-12 as primary series with this script?

        Same issue if you just go with :

        Add(PeriodType.Day, 1);
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi,

          Yes ALSI 06-12 is the primary series. I tried just using:
          Add(PeriodType.Day, 1);

          And now I get a different error. I have attached the screenshot.

          The ALSI instrument is created from tick data that i've loaded from text files. It is not supported by my data service provider. None of my other strategies seem to have a problem. It seems to have something to do with me trying to load the 2nd data series and that data series not being provided by my data provider. It needs to get the data locally.

          Any ideas to get this working?
          Attached Files

          Comment


            #6
            Did you create daily data on import from this data? If you check the Historical Data Manager is this listed as needed? If yes please try running the same test with 'GetDataFromServer' in Tools > Options > Data unchecked. Any change?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hi,

              Yes I created daily data from the import and I am able to create a daily chart based on this data. I have now unchecked the get data from server option but im still getting the attached error ("provider does not support market data").

              When I setup the ALSI instrument I added "ALSI" to all the symbol maps for each data provider because when I just left them blank it wouldn't let me save it. It has worked fine so far with all my other strategies. It's just creating an issue now when I try to add the 2nd data series through code.
              Attached Files

              Comment


                #8
                Thanks, same if you just add one map, the Simulator one? That should be enough for the symbol to be saved / managed by NT.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Hi. Yes the same error is displayed if I only enter ALSI into the Simulator map.

                  I am connecting to the Kinetic end of day free data source. Could that have anything to do with the problem? Because I cant attach a strategy to my chart unless I am connected to a data source.

                  Is there any other way of referencing the daily ATR instead of adding it? (if we cant get this error working?)
                  Last edited by DarkPool; 05-30-2012, 10:20 AM.

                  Comment


                    #10
                    Darkpool, you could also connect to the External Feed as non-documented workaround to enable applying strategies to your chart.

                    Another, yet much more involved way would be self calculating the ATR value needed from your primary series data.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Ok, thanks for the help. I have connected to the External feed but now nothing happens. No errors, and my strategy doesn't appear on the chart.

                      I guess what is happening is when I add the 2nd data series it is trying to get it from the data feed instead of locally? Very frustrating since the main data series works fine.

                      Comment


                        #12
                        You are welcome - how much data do you load for the chart? Are you sure the 20 bars required setting is satisfied for all series, so your daily, too? Otherwise OnBarUpdate() for this strategy would never be called...
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Hi. Yes I have loaded over 100 days of data.

                          I did a test now and commented out the code where I add the 2nd data series. The strategy then loads correctly. If I then uncomment the code and add the 2nd data series, there are no errors but the strategy does not appear on the chart. I am not even doing anything with the 2nd data series, I am just testing to see if I can add it.

                          Comment


                            #14
                            It would be best if I test your setup here if you don't mind sending this into us at support @ ninjatrader dot com

                            So after enabling it, there would be no error noted in the log tab, correct?

                            If you add another series, let's say 1440 min emulating a daily, same issue?
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              Thanks, adding a 1440min data series seems to work fine. In that case I guess I could just use the 1440min instead of the 1day?

                              If not, then I will send this in to support as you sugessted.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Christopher_R, Today, 12:29 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post Christopher_R  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              166 responses
                              2,235 views
                              0 likes
                              Last Post sidlercom80  
                              Started by thread, Yesterday, 11:58 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post thread
                              by thread
                               
                              Started by jclose, Yesterday, 09:37 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post jclose
                              by jclose
                               
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              10 responses
                              1,415 views
                              0 likes
                              Last Post Traderontheroad  
                              Working...
                              X