• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

First tick of bar

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

    First tick of bar

    Hi guys

    I'm utilizing the IsFirstTickOfBar property with the calculate mode set to OnPriceChange. When debugging this behaviour I see that the first tick is actualy the first tick after the middle of the bar (blue arrow) which is odd because based on the bar index it should be at the red arrow. Is this an error or do I misinterpret?

    https://ibb.co/famaZ9


    #2
    Hello Vanderbeke,

    Thank you for your note.

    The chart does not have a price axis, time duration or instrument so its not possible to debug this based on the information provided.

    Would you please provide detailed steps on how to test the behavior?

    Also please include the version of NinjaTrader you're using. For example 8.0.12.2 64-bit.

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hello Alan

      Thanks for the reply.

      Below you can find an image with more information. I'm using NinjaTrader version 8.0.15.1 64-bit.

      https://ibb.co/kAWuwp

      Comment


        #4
        Hello Vanderbeke,

        Thank you for your note.

        Without the full code we're unable to test on our end.

        If you'd like to upload the full code I can take a look and see if anything jumps out. Or if you'd prefer to email a copy, send to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread, and the files.

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hi Alan

          It's pretty straight forward. If you look at the output or put your debugger on it you will see that the FirstTickOfBar actualy refers to the first bar with a time greater than that of the previous bar. In this case it looks at the time of the 377 tick bar and then to determine the first tick it looks at the first 1 tick bar with a time greater than the 377 tick bar which isn't correct.

          Code:
                  protected override void OnStateChange()
                  {
                      if (base.State == State.SetDefaults)
                      {
                          base.Calculate          = Calculate.OnPriceChange;
                          base.IsUnmanaged        = true;
                      }
                      else if (base.State == State.Configure)
                      {
                          AddDataSeries(BarsPeriodType.Tick, 1);
                      }
                  }
          
                  protected override void OnBarUpdate()
                  {
                      if (CurrentBar < this.ATRSlow)
                          return;
          
                      if (BarsInProgress == 0)
                      {
                          if (IsFirstTickOfBar)
                          {
                              Print(string.Format("Bar index: {0}; Time: {1}; O: {2}; H: {3};L: {4}; C: {5}", CurrentBar, Bars.GetTime(CurrentBar), Open[0], High[0], Low[0], Close[0]));
                          }
                      }
                      else if (BarsInProgress == 1)
                      {
                          Print(string.Format("Bar index: {0}; Time: {1}; O: {2}; H: {3};L: {4}; C: {5}", CurrentBar, Bars.GetTime(CurrentBar), Open[0], High[0], Low[0], Close[0]));
                      }
                  }

          Comment


            #6
            Hi Alan

            I just notice that when I open a chart with on top 377 tick bars and below 1 tick bars that the bar index of the above charts switches to 1 on bar 565 of the 1 tick chart. Is there a reason this is the case and not 377?

            Comment


              #7
              Hello Vanderbeke,

              I'm replying on behalf of Alan who is out of the office today.

              CurrentBar will represent the bar index of the iterating data series. For BarsInProgress 0, you will print the bar index for the primary data series. CurrentBar on BarsInProgress 1 will represent the bar index of the 1 tick data series that is added to the script.

              Adding a 1 tick data series to a chart that is identical to the added data series will change the indexes of that data series if there is more data requested by the chart.

              I have attached a demonstration explaining further - https://drive.google.com/file/d/1xZ0...w?usp=drivesdk

              Please let us know if you have any additional questions.
              JimNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jamarc, Today, 02:30 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by uday12, Yesterday, 04:19 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by grose, Today, 06:53 AM
              2 responses
              6 views
              0 likes
              Last Post grose
              by grose
               
              Started by Bobisam, Yesterday, 04:57 PM
              1 response
              20 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by voltlon, Yesterday, 05:18 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Working...
              X