• 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

FirstTickOfBar

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

    FirstTickOfBar

    Hi,
    This may be related to something I reported on time bars a while back, but I thought that was fixed, and I'm now using volume bars.

    Time[0] and Time[1] reference the same bar when used on FirstTickOfBar; i.e., the follwing code produces repeated lines.

    if (FirstTickOfBar)
    {
    Print(Time[1].ToLongTimeString());
    Print(Time[0].ToLongTimeString());
    }

    - palinuro

    #2
    Please post reproducible steps. Thank you.
    JoshNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      Please post reproducible steps. Thank you.
      Sorry, I appear to have been mistaken about the timestamp - it appears to be the barstamp at FirstTickOfBar. The new PercentComplete seems to be assigned both to the last tick of the last bar and the first tick of the new bar. See attached pic - output is CurrentBar followed by PercentComplete.
      Attached Files

      Comment


        #4
        palinuro,

        I'm not sure I follow you exactly, but perhaps this provides info for you. To determine a bar close, a new bar has to start building. The first tick of a new bar is essentially the same event that closes the prior bar.
        JoshNinjaTrader Customer Service

        Comment


          #5
          So that is intentional? I'm using PercentComplete to prorate time over a bar. If the very last tick assigned to (in that photo) bar 13698 suddenly has the PercentComplete of the first tick of the next bar, the indicator value suddenly drops down to almost zero as it is assigned to the previous bar. So 100 seconds, for example, suddenly drops to 100 seconds * 0.01 (rather than * 1) just as the bar completes. That's the problem I had, which led me to investigate.

          Since discovering this, I've set up a workaround by simply not prorating the value for the first 10% of the bar (thus skipping the first tick). So it isn't critical any longer. But it doesn't seem correct that the same PercentComplete on the first tick should be assigned to both the previous bar 13698 and the forming bar 13699.

          Comment


            #6
            I do not know how you have coded it, but the only way NT knows a bar has closed is if an incoming tick starts building a new bar. If you were on a 100 sec bar and 100 seconds passed but no new tick came out in to inform it that 100 seconds has passed, that bar will remain open until it does receive a tick signifying a close.

            For sure you would be assigning the same value if you waited till if (FirstTickOfBar) to assign PercentComplete. You have already started up the next bar and at that point in time the PercentComplete is based off of the new bar.
            JoshNinjaTrader Customer Service

            Comment


              #7
              Josh, if you look at the jpeg I uploaded, Bar # 13698 suddenly drops from 0.989.... PercentComplete to 0.002... PercentComplete. That's not a result of my indicator code, it's what NT reports. Isn't it reasonable to think that PercentComplete should always increase on the same bar until it achieves 100%?
              Last edited by palinuro; 01-23-2009, 02:14 AM.

              Comment


                #8
                palinuro,

                If you are accessing it with if(FirstTickOfBar) you are accessing the new bar already. The close bar event is the same as the opening of a new bar. When you start up a new bar PercentComplete will be the percent complete of the new bar, not of the closed bar. This is exactly what you are seeing and this is expected behavior.
                JoshNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  palinuro,

                  If you are accessing it with if(FirstTickOfBar) you are accessing the new bar already. The close bar event is the same as the opening of a new bar. When you start up a new bar PercentComplete will be the percent complete of the new bar, not of the closed bar. This is exactly what you are seeing and this is expected behavior.
                  Perhaps I'm missing something, but if so I don't get it. I'm not accessing anything with FirstTickOfBar, I just put that there as a marker.

                  Before that, and before the new bar is processed, the PercentComplete value of the old bar suddenly drops. Here's the jpeg reduced to the essentials - only the old bar. The code Prints CurrentBar (#13698) and PercentComplete of CurrentBar.
                  Attached Files

                  Comment


                    #10
                    Please post your complete code. Thank you.
                    JoshNinjaTrader Customer Service

                    Comment


                      #11
                      Print ("Bar # " + CurrentBar.ToString() + " " + Bars.PercentComplete.ToString() +" %");
                      if (FirstTickOfBar)
                      {
                      Print ("FirstTickOfBar " + CurrentBar.ToString() + " " + Bars.PercentComplete.ToString() +" %");
                      }

                      Comment


                        #12
                        Which instrument? Please provide reproducible steps. Thank you.
                        JoshNinjaTrader Customer Service

                        Comment


                          #13
                          That was ES 03-09 2401 Volume Bars, ZenFire feed.

                          Comment


                            #14
                            I am able to reproduce now. I will investigate it and let you know.
                            JoshNinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Josh View Post
                              I am able to reproduce now. I will investigate it and let you know.
                              At last! I was beginning to feel a wee bit frustrated.

                              Thank you, Josh.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by fx.practic, Today, 03:10 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post fx.practic  
                              Started by jertrade, Today, 02:50 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post jertrade  
                              Started by Emma1, Today, 02:42 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Emma1
                              by Emma1
                               
                              Started by RedDuke, Today, 01:59 PM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_Kate  
                              Started by MarianApalaghiei, Today, 01:18 PM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_PatrickG  
                              Working...
                              X