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

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?




    #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.

      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 kevinenergy, 02-17-2023, 12:42 PM
              115 responses
              2,699 views
              1 like
              Last Post kevinenergy  
              Started by prdecast, Today, 06:07 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by Christopher_R, Today, 12:29 AM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by chartchart, 05-19-2021, 04:14 PM
              3 responses
              577 views
              1 like
              Last Post NinjaTrader_Gaby  
              Started by bsbisme, Yesterday, 02:08 PM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X