Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

First and LastVisible Bar

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

    First and LastVisible Bar

    Hi

    Is there any method to know the bar index of the first and last visible bars on a chart?

    Tanks in advance !

    #2
    Hello

    Welcome to the NinjaTrader Support Forums!

    Please clarify what you are looking to do. Do you have a screenshot or an example that you can provide?
    ChipNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Chip View Post
      Hello

      Welcome to the NinjaTrader Support Forums!

      Please clarify what you are looking to do. Do you have a screenshot or an example that you can provide?
      Hi again !

      What Im trying to make is a kind of an histogram of volume. I would like to sum all the volume that was traded for a given price and display it. But I want to limit that sum to the volume corresponding to the price bars visible on screen at a given moment. So, I need the index of the first and last visible bars, to exclude all the other bars in the data serie.

      Comment


        #4
        Hello

        If I understand you correctly, this would be possible but would require custom programming in NinjaScript.

        This link will take you to the NinjaScript section of our Help Guide:


        NinjaScript File Sharing:


        NinjaScript Development Support:


        NinjaScript Educational Resources:


        Please let me know if you have any additional questions.
        ChipNinjaTrader Customer Service

        Comment


          #5
          this gets you close.... it will give you the number of bars that can be displayed on the screen... I'll keep digging, I know I've see this...

          // calculates the number of bars on the chart
          intFirstBarOnChart = ChartControl.FirstBarPainted;
          intLastBarOnChart = ChartControl.LastBarPainted;
          intBarsOnChart = intLastBarOnChart - intFirstBarOnChart;

          UPDATE....

          I knew I had done this before.... the approach is to count all the bars printed and store in a variable such as total_number_of_bars then subtract ChartControl.FirstBarPainted; This will give you the total number of bars visible on the screen (you may have to add 1 as bars are 0 based). If your using CalculateOnBarClose=true, just initialize a counter to 0 in the initialize method and increment the counter the very first line in the OnBarUpdate method.

          ChartControl.LastBarPainted - ChartControl.FirstBarPainted will give you the same value as ChartControl.BarsPainted, that being the total possible bars that could be visible on the screen.

          If you have adjusted the screen, scrolling the chart off the to the left leaving an open right side edge, use total_number_of_bars - ChartControl.FirstBarPainted

          UPDATE 2

          the Count system value can be used in place of counting the bars, it is the total bars for your current plot.
          Last edited by tulanch; 01-12-2012, 10:08 PM.

          Comment


            #6
            Originally posted by yabadoo View Post
            Hi

            Is there any method to know the bar index of the first and last visible bars on a chart?

            Tanks in advance !
            Take a look at this post that I made a while back. http://www.ninjatrader.com/support/f...83&postcount=5

            Comment


              #7
              ChartControl.BarsPainted == ChartControl.LastBarPainted -ChartControl.FirstBarPainted +1

              There are ghost bars? , Maybe. The fact is that if you move the chart to the left beyond the last bar, "ChartControl.LastBarPainted" points to the position that would occupy the last bar painted, even if does not exist.

              I think it is right:
              int Barspainted = Bars.Count - ChartControl.FirstBarPainted;
              Last edited by Ramon; 02-24-2012, 05:02 AM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Waxavi, Today, 02:10 AM
              0 responses
              3 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by TradeForge, Today, 02:09 AM
              0 responses
              9 views
              0 likes
              Last Post TradeForge  
              Started by Waxavi, Today, 02:00 AM
              0 responses
              2 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by elirion, Today, 01:36 AM
              0 responses
              4 views
              0 likes
              Last Post elirion
              by elirion
               
              Started by gentlebenthebear, Today, 01:30 AM
              0 responses
              4 views
              0 likes
              Last Post gentlebenthebear  
              Working...
              X