Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TickCount

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

    TickCount

    Hello,

    with Bars.Tickcount we get the Ticks of currentbar it seems. Cant find the syntax in the helpguide how one get Ticks of Bar[1] and Bar[2] in a minute chart. What would be the syntax/snippet please?

    Thank you!
    Tony
    Last edited by tonynt; 04-11-2021, 12:48 PM. Reason: typo

    #2
    Hello tonynt,

    There is no collection for this.

    You could create a custom Series<int>, and save this value on each bar.
    https://ninjatrader.com/support/help...t8/seriest.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply. It seems I do not understand that doubles series.

      For having only the ticks of the Bar[1] I thought I could do it easily with
      if(IsFirstTickOfBar)
      {trades1 = Bars.TickCount;}

      but the result shows always 1.

      How can I store the Bars.TickCount of Bar[1] please?

      Thank you!
      Tony

      Comment


        #4
        Hello Tony,

        In post #2, I have suggested an int (integer) series, Series<int>.

        private Series<int> tickCountSeries;

        tickCountSeries = new Series<int>(this);

        tickCountSeries[0] = Bars.TickCount;

        Print(tickCountSeries[0]);

        When IsFirstTickOfBar is true, the number of ticks that have been received in that new open bar is 1. This means TickCount will be 1.

        Assign a variable to hold TickCount on every tick. When IsFirstTickOfBar is true, don't set it first, instead save it to the series, then set it to 1 after the value is saved.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          thank you for your reply. I tried to do but I get the error in log "
          20.04.2021 14:14:15 Default Indicator 'TxVolTickxV21': Error on calling 'OnBarUpdate' method on bar 3: Object reference not set to an instance of an object.
          I dont know what I´m doing wrong and how it should be done.

          Thank you!
          Tony

          Comment


            #6
            In this case you are trying to access a bar that doesn't exist, a bar before bar zero (0), the first bar.
            eDanny
            NinjaTrader Ecosystem Vendor - Integrity Traders

            Comment


              #7
              Hello,
              I have in onbarupdate
              if(CurrentBars[0]<3)
              return;
              tickCountSeries[0] = Bars.TickCount;
              Print(tickCountSeries[0]);
              tickValue=tickCountSeries[0];

              What would I need to modify please for having the ticks of Bar[1]

              Thank you!
              Tony

              Comment


                #8
                Hello Tony,

                What specifically is null?

                is tickCountSeries null?

                if (tickCountSeries == null)
                Print("tickCountSeries is null");
                else
                Print("tickCountSeries is not null");
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello,

                  how does this help me to get the ticks of the bar[1] please?
                  I tried to retrieve from an indicator using new Series<int>(this); but I cant find there where this is set to null.

                  Thank you!
                  Tony

                  Comment


                    #10
                    Hello Tony,

                    Is that in State.DataLoaded?

                    What do you mean by 'I tried to retrieve from an indicator'?

                    Is this coming from another script?

                    Is the originating script is the variable holding the series null?

                    What prints to the output window?

                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello,

                      with retrieve I mean I tried to follow the logic in another indicator and to apply it here. But in the other indicator its series<bool> so from this I cant get it for doubles or ints.

                      Isn´t there a small example how to work with series of doubles or ints to access the values of Bar[1] or Bar [2].? When I was searching before starting the thread I saw a lot of questions about this topic. So a small sample with the few lines necessary would help a lot of users.

                      Thank you!
                      Tony

                      Comment


                        #12
                        Hello Tony,

                        Use an Series<int> instead of a Series<bool>.

                        There is a code sample in the help guide but this focuses on Series<double>, but once you have a full understanding of series objects, it doesn't matter what type is used as long as the type is appropriate for the value that will be saved.

                        https://ninjatrader.com/support/help...t8/seriest.htm
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello,

                          thank you for your reply. I could make it running from this snippets in the link. What I do not understand is if Bars.TickCount is counting ticks only when indicator is set to calculate on each tick or does it also count ticks when I run the indicator with calculate on bar close. (I know I have to access the bars differently depending on this but this is not the question). I experienced from my backcoloring which works best for me to debug that it was plotting ok when I forgot to set in parameters to calculate on each tick. So this would be the best solution because of pc ressources.

                          Does Bars.Tickcount the ticks with calculateonbarclose so that I can have with myIntSeries[0] = Bars.TickCount; theTicks of a minute bar [0] bar [1] bar[2]...?

                          Thank you!
                          Tony

                          Comment


                            #14
                            Hello Tony,

                            The Bars.TickCount continues to count even when Calculate is OnBarClose. In historical data TickReplay is required.
                            https://ninjatrader.com/support/help.../tickcount.htm


                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello,

                              thank you for your reply. So my observation was correct. I could make my indicator running now with cobcfalse and with cobctrue.

                              Thank you!
                              Tony
                              Last edited by tonynt; 04-30-2021, 06:28 AM. Reason: resolved

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by aligator, Today, 02:38 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post aligator  
                              Started by Stett0002, Yesterday, 11:55 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by KasLB, Today, 05:12 AM
                              2 responses
                              17 views
                              1 like
                              Last Post KasLB
                              by KasLB
                               
                              Started by LeitoGTR, Yesterday, 06:41 PM
                              2 responses
                              13 views
                              0 likes
                              Last Post LeitoGTR  
                              Started by Prisalice, Today, 07:07 AM
                              1 response
                              10 views
                              0 likes
                              Last Post NT-Roland  
                              Working...
                              X