• 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

Last Historical Bar?

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

    Last Historical Bar?

    Any suggestion on how to trigger OnBarUpdate on last historical bar only?

    Bars.LastHistorical or Bars.Loaded properties would be handy properties for this purpose.

    The indicator I´m working with uses Infinite lookback and performs all historical calculations (0 -> CurrentBar looping) on each bar - hence last historical/current bar update only would make loading faster.

    Kindly, Fredrik
    Last edited by FREEN; 11-09-2011, 03:25 AM.

    #2
    Hi Frederik, try doing your calcs then in a condition like this :

    if (Bars.Count - 2 == CurrentBar && Historical)
    {
    do calcs on last historical bar
    }
    BertrandNinjaTrader Customer Service

    Comment


      #3
      HI Guys,

      I would like to do exactly what Freen has requested here.

      Bertrand, I tried your solution.... am I missing something here because your suggested code still only allows the indicator to load if it is the last bar on the chart. "Bars.Count" returns the same value as "Count" for me. So therfore your code will skip every bar until we are at Count - 2 which is when all historical bars are already loaded. What if we want the indicators code to only initiate once the CurrrentBar has arrived at the current scroll point of the chart?

      Comment


        #4
        Can you clarify the meaning of "scroll point"? A screenshot with your notes on it will easily explain.
        ninZa
        NinjaTrader Ecosystem Vendor - Ninza

        Comment


          #5
          Originally posted by marty087 View Post
          HI Guys,

          I would like to do exactly what Freen has requested here.
          Then you are not doing exactly what Freen is doing.

          Comment


            #6
            Originally posted by ninZa View Post
            Can you clarify the meaning of "scroll point"? A screenshot with your notes on it will easily explain.
            Scroll point in the sense last bar on screen, that might not be bars.count.

            Comment


              #7
              Originally posted by ninZa View Post
              Can you clarify the meaning of "scroll point"? A screenshot with your notes on it will easily explain.
              See pic for clarification
              Attached Files

              Comment


                #8
                In short....

                CurrentBar returns the id of the last bar displyed on the right of the screen irrecpective of whether the chart is scrolled to the end or not.

                Count OR Bars.Count returns how many bars are in the chart once fully loaded / scrolled to the right alll the way

                So..... if i am in the middle of the chart and want my indicator to only execute once it has arrived at the furtherest scrooled bar, is there any way to do this?

                FREEN, is it fair to say that the supplied code below (Bertrand's contribution) didnt provide a solution for you?

                Cheers Guys.

                Comment


                  #9
                  marty087, please try LastBarIndexPainted. I'm not sure this works in your case. This will give you the last bar painted on chart after the bars are loaded. In your case, you want to get the value in advance, so I'm not sure. Please test it, if it doesn't work, we will have to take another approach.

                  Thanks.
                  Last edited by ninZa; 02-04-2015, 01:22 AM.
                  ninZa
                  NinjaTrader Ecosystem Vendor - Ninza

                  Comment


                    #10
                    Originally posted by marty087 View Post
                    In short....

                    CurrentBar returns the id of the last bar displyed on the right of the screen irrecpective of whether the chart is scrolled to the end or not.

                    Count OR Bars.Count returns how many bars are in the chart once fully loaded / scrolled to the right alll the way

                    So..... if i am in the middle of the chart and want my indicator to only execute once it has arrived at the furtherest scrooled bar, is there any way to do this?

                    FREEN, is it fair to say that the supplied code below (Bertrand's contribution) didnt provide a solution for you?

                    Cheers Guys.
                    marty087, when you are in the middle of the chart, the indicator will only execute until the last bar printed on your chart and then it will temporarily stop there, until a LIVE tick comes in. If there are no live data coming in, the indicator will not reach the actual last bar (whose index is Bars.Count - 1). You have to manually scroll your chart back to the actual last bar. This is my 30-minute inspection on the issue, need a confirmation from NT staff.

                    However, if in a live market with fast coming data, you can execute the following unsupported codes to ignore all bars until the last painted bar:


                    if (ChartControl.GetXByBarIdx(BarsArray[0], CurrentBar) < ChartControl.CanvasRight) return;
                    Cheers.
                    Pi
                    Last edited by ninZa; 02-04-2015, 02:08 AM.
                    ninZa
                    NinjaTrader Ecosystem Vendor - Ninza

                    Comment


                      #11
                      Originally posted by ninZa View Post
                      marty087, please try LastBarIndexPainted. I'm not sure this works in your case. This will give you the last bar painted on chart after the bars are loaded. In your case, you want to get the value in advance, so I'm not sure. Please test it, if it doesn't work, we will have to take another approach.

                      Thanks.
                      BOOM! Worked a charm. Where did you pull that one from?

                      Thanks.
                      Attached Files

                      Comment


                        #12
                        Originally posted by marty087 View Post
                        BOOM! Worked a charm. Where did you pull that one from?

                        Thanks.
                        It works actually? I'm not sure, so I gave you another solution above.

                        I don't remember where I got the info of LastBarIndexPainted. Perhaps searched something on Google and found it.

                        Regards.
                        Pi
                        ninZa
                        NinjaTrader Ecosystem Vendor - Ninza

                        Comment


                          #13
                          Originally posted by ninZa View Post
                          It works actually? I'm not sure, so I gave you another solution above.

                          I don't remember where I got the info of LastBarIndexPainted. Perhaps searched something on Google and found it.

                          Regards.
                          Pi
                          Great stuff. Thanks again

                          Comment


                            #14
                            Originally posted by marty087 View Post
                            BOOM! Worked a charm. Where did you pull that one from?

                            Thanks.
                            Probably from here: http://www.ninjatrader.com/support/f...d.php?p=261631

                            Though, given his skills, Ninza may have come upon that independently.

                            Comment


                              #15
                              Originally posted by koganam View Post
                              Probably from here: http://www.ninjatrader.com/support/f...d.php?p=261631

                              Though, given his skills, Ninza may have come upon that independently.
                              My skill is googling Koganam lol.

                              Regarding your comment about the dependence on COBC, should we reverse the order? I mean the 1st one (ChartControl) should be absolute, and the 2nd one is dependent on COBC?
                              Last edited by ninZa; 02-04-2015, 05:21 PM.
                              ninZa
                              NinjaTrader Ecosystem Vendor - Ninza

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by frankduc, Today, 07:02 AM
                              0 responses
                              0 views
                              0 likes
                              Last Post frankduc  
                              Started by i2w8am9ii2, Today, 06:57 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post i2w8am9ii2  
                              Started by sidviciousX, Today, 06:47 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post sidviciousX  
                              Started by buzzripper, Today, 06:14 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post buzzripper  
                              Started by NinjaCustomer, Today, 06:04 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post NinjaCustomer  
                              Working...
                              X