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

How many bars in screen?

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

    How many bars in screen?

    Hi there

    Just a quick question?

    How can I know how many bars are displayed in the chart currently???

    I tried with Bats.Count but it seems to give me the TOTAL number of bars, not how many can be seen in this moment.

    Thank you

    #2
    level2, unfortunately there's no method for this.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      NT7 was not released when this question was asked, so since it is here, is there now a way to count how many bars are currently on screen?

      Comment


        #4
        Hello Unhommefou,

        Yes, NT7 now offers Count:


        Edit: For bars on screen there is no supported property for this, but can try Koganam's suggestion.
        Last edited by NinjaTrader_RyanM1; 08-11-2011, 08:38 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by Unhommefou View Post
          NT7 was not released when this question was asked, so since it is here, is there now a way to count how many bars are currently on screen?
          Code:
           
          int intFirstBarOnChart = ChartControl.FirstBarPainted;
          int intLastBarOnChart = ChartControl.LastBarPainted;
          int intBarsOnChart = intLastBarOnChart - intFirstBarOnChart;
          You must be aware, and understand, that ChartControl access will not get any support from NT Support. They will not even answer questions about it.

          Use at your own discretion.
          Last edited by koganam; 08-11-2011, 07:09 PM.

          Comment


            #6
            Originally posted by koganam View Post
            Code:
             
            int intFirstBarOnChart = ChartControl.FirstBarPainted;
            int intLastBarOnChart = ChartControl.LastBarPainted;
            int intBarsOnChart = intLastBarOnChart - intFirstBarOnChart;
            You must be aware, and understand, that ChartControl access will not get any support from NT Support. They will not even answer questions about it.

            Use at your own discretion.
            This worked perfect for me just wanting the indicator printing on shown candles and not all the way back in history. I appreciate the tip.

            Comment


              #7
              In NT8 "FirstBarPainted" and "LastBarPainted" are no members of the ChartTrader object anymore. Is it possible to retrieve the values with NT8?

              Comment


                #8
                Originally posted by BearingHH View Post
                In NT8 "FirstBarPainted" and "LastBarPainted" are no members of the ChartTrader object anymore. Is it possible to retrieve the values with NT8?
                Would suggest for NT8 now you peek into the ChartBars class's FromIndex and ToIndex - https://ninjatrader.com/support/help...?chartbars.htm
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by koganam View Post

                  Code:
                  int intFirstBarOnChart = ChartControl.FirstBarPainted;
                  int intLastBarOnChart = ChartControl.LastBarPainted;
                  int intBarsOnChart = intLastBarOnChart - intFirstBarOnChart;
                  You must be aware, and understand, that ChartControl access will not get any support from NT Support. They will not even answer questions about it. diebestetest
                  Exactly what I needed! You just saved me several hours. Thanks!

                  Comment


                    #10
                    bandass,

                    This could be done in OnRender(). Please see the example of looping through the charts visible bars in this helpguide link: https://ninjatrader.com/support/help..._fromindex.htm

                    Other references that may be of interest are:
                    https://ninjatrader.com/support/help...?chartbars.htm
                    Josh G.NinjaTrader Customer Service

                    Comment


                      #11
                      if a chart has 100 bars of data, the very first bar of the chart (left most bar) will be number 0 (zero) and each subsequent bar from left to right is incremented by 1.
                      Spankbang
                      Last edited by samanthagates29; 06-10-2019, 10:32 AM.

                      Comment


                        #12
                        Hello samanthagates29,

                        Welcome to the NinjaTrader forums!

                        The very first bar of data is bar 0. This would be the first bar if the chart is scrolled all the way to the left.
                        However, if the chart is not scrolled all the way to the left, the first visible bar is ChartBars.FromIndex.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by michi08, 10-05-2018, 09:31 AM
                        5 responses
                        741 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by The_Sec, Today, 02:29 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post The_Sec
                        by The_Sec
                         
                        Started by tsantospinto, 04-12-2024, 07:04 PM
                        4 responses
                        62 views
                        0 likes
                        Last Post aligator  
                        Started by sightcareclickhere, Today, 01:55 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post sightcareclickhere  
                        Started by Mindset, 05-06-2023, 09:03 PM
                        9 responses
                        259 views
                        0 likes
                        Last Post ender_wiggum  
                        Working...
                        X