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

Is there a way to code an indicator on 1 Tick period that works on other periods too?

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

    Is there a way to code an indicator on 1 Tick period that works on other periods too?

    Hello,
    I coded and indicator that has to do the calc on 1 tick period, but I would like to see what it plots also on others periods, is there a way to do this?
    Thanks.
    Lubo.

    #2
    Hi Lubo,

    We added support for multiple series indicators in version 7. Documentation for this is available here:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hi Lubo,

      We added support for multiple series indicators in version 7. Documentation for this is available here:
      http://www.ninjatrader.com/support/h...nstruments.htm
      Thanks,
      but is not what i really want to do, in this way i have to Add() every Period in the script, is not very practical.

      Comment


        #4
        Lubo, I'm not sure I follow you, why don't you restructure it and Add() the 1 tick series to to the calcs then on internally, this way you could use various primary series.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Lubo, I'm not sure I follow you, why don't you restructure it and Add() the 1 tick series to to the calcs then on internally, this way you could use various primary series.
          Thanks Bertrand,
          could u elaborate more maybe with some example?
          What I would like is specify in the code that the calcs is on the 1 tick series and then plot the indicator on every chart period I want choise. I don't undestand if this is possible.
          Thanks.
          Lubo.

          Comment


            #6
            Hi Lubo,

            You can do this and it's with a multiple series indicator. Use the link included earlier for help with multiple series. Add a 1 tick series and all your calculations will then use BarsArray[1], Closes[1].

            A sample multitime frame series is available by Clicking Tools > Edit NinjaScript > Strategy > Sample MultiTimeFrame.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Thanks I have done it.
              The multi time frame sample and documentation confused me, I have not understood that just use add() with only 1 bar period series will do the calcs on it and can be used to plot the indicator on every bar period chart.
              The weird is that my indicator works well on 6E and 6B on minute bar, but for example on CL if I change the standard setting it works only on ticks builded bar, but not on minute.
              Any idea?

              Comment


                #8
                Hello,

                Unfortunately I wouldn't have an idea unless I looked at the code and tested it on my end to help you debug it. Would you mind posting it so that I may take a look at the code and run it on my side and see if I run into the same issue. If you do not want to post it to the forum please send it as an attachment to support at NinjaTrader dot com and reference this forum post and I will take a quick look.

                I look forward to assisting you further.

                Comment


                  #9
                  Thanks Brett,
                  at the moment I would try to resolve myself, this is the error I get :

                  "Error on calling 'OnBarUpdate' method for indicator '.............' on bar 25: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

                  But another problem arise, I'm not able anymore to add others indicators when I have mine on chart that NT 7 b 22 crashes, and I have to force the close, no errors appers then on log.
                  Lubo.
                  Last edited by LuboLabo; 10-15-2010, 10:06 AM.

                  Comment


                    #10
                    Ok if I load a tick chart with more days then the minute chart I resolve the crash issue, but not the error calling OnBarUpdate()....that happens on some instruments.

                    Lubo.

                    Comment


                      #11
                      Hi Lubo,

                      You are running into this issue:
                      Make sure you have enough bars in the data series you are accessing

                      It's more involved with a multiple series strategy because you have to be aware of the relationship between the two series. You don't want to access values that don't exist. You need to check against CurrentBar and return when the values are not accessible.

                      If you need to check current bar value against another series, this is done with CurrentBars[]
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks RyanM,
                        I used: if (CurrentBars[1]<2) return; maybe I have to increase the # of bar to check since I use 2 tick period (not more 1 cos it takes more resources and the results is pretty the same) for the calcs and usually plot it on 1 minute period.

                        Lubo.

                        Comment


                          #13
                          If you're applying this indicator to a minute series, you also need a CurrentBar check as well.

                          It's difficult to know the exact number to use since the number of ticks / per minute is variable.

                          if (CurrentBar < x)
                          return;

                          Play around with that x value, which will be different depending on instrument, volume, etc.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            I solved the problem of Error on calling 'OnBarUpdate' method, but remains a problem, on minute data the plots are out of sync of one bar, e. if I have an event that on 2 tick data came on 16:23:32 on minute data this is plot on 16:23 bar and not on 16:24 bar.

                            Comment


                              #15
                              Lubo, it will largely depend on your code structure, if you pass over a value to another BarsInProgress to plot it could be plotted one bar later as it takes a BIP event to update it.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Jonafare, 12-06-2012, 03:48 PM
                              5 responses
                              3,986 views
                              0 likes
                              Last Post rene69851  
                              Started by Fitspressorest, Today, 01:38 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Fitspressorest  
                              Started by Jonker, Today, 01:19 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Jonker
                              by Jonker
                               
                              Started by futtrader, Today, 01:16 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post futtrader  
                              Started by Segwin, 05-07-2018, 02:15 PM
                              14 responses
                              1,792 views
                              0 likes
                              Last Post aligator  
                              Working...
                              X