• 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

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:
        http://www.ninjatrader-support.com/H...tml?Overview17

        NinjaScript File Sharing:
        http://www.ninjatrader-support2.com/...splay.php?f=37

        NinjaScript Development Support:
        http://www.ninjatrader-support2.com/...isplay.php?f=6

        NinjaScript Educational Resources:
        http://www.ninjatrader-support2.com/...splay.php?f=29

        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, 09: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, 04:02 AM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by tonynt, Today, 02:21 AM
              0 responses
              4 views
              0 likes
              Last Post tonynt
              by tonynt
               
              Started by alstsion, Today, 12:55 AM
              0 responses
              1 view
              0 likes
              Last Post alstsion  
              Started by kandster, Yesterday, 11:49 PM
              0 responses
              3 views
              0 likes
              Last Post kandster  
              Started by priceisking, Yesterday, 05:33 PM
              0 responses
              26 views
              0 likes
              Last Post priceisking  
              Started by vivekniwas, Yesterday, 02:15 PM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Working...
              X