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

The last displayed bar on the chart screen

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

    The last displayed bar on the chart screen

    Hi,
    for my discretionary strategy backtesting I have to quickly see some information about last displayed bar on the screen. When I'm browsing in history I always want to see these informations about last bar. I don't know where to get the reference to this bar.

    Thanks

    #2
    Welcome to our forums yaris - unfortunately accessing this info via a NinjaScript study would not be supported.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by yaris View Post
      Hi,
      for my discretionary strategy backtesting I have to quickly see some information about last displayed bar on the screen. When I'm browsing in history I always want to see these informations about last bar. I don't know where to get the reference to this bar.

      Thanks
      Not sure that I understand what you are seeking. You need to see this information. Where and how are you seeking to display that information? Getting the last bar displayed on the chart and using it as an offset from CurrentBar should give you access to the bar's properties.
      Last edited by koganam; 11-03-2011, 02:31 PM. Reason: Corrected punctuation

      Comment


        #4
        Thanks for reply. But how can I get the last bar displayed from indicator code? I'm looking in this.ChartControl properties, but I don't see anything usable.

        Comment


          #5
          What I want to do, is the same as the small floating data window accessible by middle mouse button in chart, but always visible in top left corner of chart window and referenced to the right most displayed bar. Not to a position of cursor.

          Comment


            #6
            Hi Yaris,

            It seems like a good idea. Unfortunately there are not supported NinjaScript properties for identifying the right-most displayed bar.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by yaris View Post
              What I want to do, is the same as the small floating data window accessible by middle mouse button in chart, but always visible in top left corner of chart window and referenced to the right most displayed bar. Not to a position of cursor.
              I am going to assume then that all you want is how to get the index of the last bar showing on the screen, and that you know how to query and display the information on the screen with DrawTextFixed()? If that is correct, then there are 2 ways to get the last bar painted, both undocumented and unsupported by NT Support, so do not even ask.
              1. int intLastBarOnChart = ChartControl.LastBarPainted;
              2. int intLastBarPaintedOnChart = this.LastBarIndexPainted;

              The first index is dependent on the COBC property; the second one is absolute.

              Comment


                #8
                Originally posted by yaris View Post
                What I want to do, is the same as the small floating data window accessible by middle mouse button in chart, but always visible in top left corner of chart window and referenced to the right most displayed bar. Not to a position of cursor.
                Yaris,

                We have a new customizable DataBox that can be configured to do exactly what you're looking for. You can check it out and find out more information on our website to see if it meets your needs.

                Integrated Trading Technologies

                VT

                Comment


                  #9
                  Originally posted by NinjaTrader_RyanM View Post
                  Hi Yaris,

                  It seems like a good idea. Unfortunately there are not supported NinjaScript properties for identifying the right-most displayed bar.
                  Pardon my ignorance . . but isn't that bar 0 ?

                  Comment


                    #10
                    Originally posted by RaptorUK View Post
                    Pardon my ignorance . . but isn't that bar 0 ?
                    The rightmost displayed bar, not the rightmost bar, which would be bar0.

                    Comment


                      #11
                      Originally posted by koganam View Post
                      I am going to assume then that all you want is how to get the index of the last bar showing on the screen, and that you know how to query and display the information on the screen with DrawTextFixed()? If that is correct, then there are 2 ways to get the last bar painted, both undocumented and unsupported by NT Support, so do not even ask.
                      1. int intLastBarOnChart = ChartControl.LastBarPainted;
                      2. int intLastBarPaintedOnChart = this.LastBarIndexPainted;

                      The first index is dependent on the COBC property; the second one is absolute.
                      The frist index looks good but works little unpredictable. There is a shift of 1, but not always. I have to do more tests.


                      Thanks. I'm going to write some code, not post.

                      DrawTextFixed(
                      "Bottom", High[this.Bars.Count - this.LastBarIndexPainted].ToString() + "\n" + Low[this.Bars.Count - this.LastBarIndexPainted].ToString() , TextPosition.TopLeft, Color.Black, textFont, Color.Transparent, Color.Transparent, 10 );

                      Comment


                        #12
                        Originally posted by yaris View Post
                        The frist index looks good but works little unpredictable. There is a shift of 1, but not always. I have to do more tests.


                        Thanks. I'm going to write some code, not post.

                        DrawTextFixed(
                        "Bottom", High[this.Bars.Count - this.LastBarIndexPainted].ToString() + "\n" + Low[this.Bars.Count - this.LastBarIndexPainted].ToString() , TextPosition.TopLeft, Color.Black, textFont, Color.Transparent, Color.Transparent, 10 );
                        As I said, the first index method depends on the COBC setting. It is consistent, not unpredictable. Your unpredictability is coming from using Bars.Count. Use CurrentBar instead.

                        Comment


                          #13
                          Here is my solution and notes.
                          To show the databox after adding indicator I have to scroll chart. Sometimes textbox is not Invalidated (shows data for another bar), so I have to click anywhere in chart area.
                          But it is good enough for me.
                          COBC have to be TRUE.
                          Unpredictability of LastBarIndexPainted is comming from textbox Invalidation.
                          Attached Files
                          Last edited by yaris; 11-04-2011, 06:28 AM.

                          Comment


                            #14
                            Sorry to be resurrecting an old thread but I have recently been investigating this as I need the last painted bar for my indicator too.

                            One difference between ChartControl.LastBarPainted and this.LastBarIndexPainted is that the latter stops incrementing when CurrentBar has been reached, and the former does not.

                            Try the following as a very simple indicator:

                            if ((Count - 2) != CurrentBar) return; //waits to last bar;
                            Print("ChartControl.LastBarPainted = " + ChartControl.LastBarPainted + " this.LastBarIndexPainted = " + this.LastBarIndexPainted + " CurrentBar = " + CurrentBar);


                            In the output window try scrolling to the right as you keep pressing F5 to refresh. Keep scrolling past the end of the chart. As you scroll past the end of the chart you will notice that this.LastBarIndexPainted will not increment past CurrentBar. However, ChartControl.LastBarPainted does keep incrementing for as long as you scroll to the right, as if the invisible bars not painted were actually painted. This shows you the current position on the chart rather than literally the last painted bar. So both chart controls are useful.

                            Comment


                              #15
                              Originally posted by koganam View Post
                              I am going to assume then that all you want is how to get the index of the last bar showing on the screen, and that you know how to query and display the information on the screen with DrawTextFixed()? If that is correct, then there are 2 ways to get the last bar painted, both undocumented and unsupported by NT Support, so do not even ask.
                              1. int intLastBarOnChart = ChartControl.LastBarPainted;
                              2. int intLastBarPaintedOnChart = this.LastBarIndexPainted;

                              The first index is dependent on the COBC property; the second one is absolute.
                              @koganam, do you know of a way to reference the right most bar that can be SEEN on a chart at all times?

                              For example, so the most right bar on the chart is 5000, if you scroll your chart by 1-bar to the left, the right most bar would then be 4999. Would it be possible to reference that bar, although the most recently loaded bar is 5000?

                              Asking more as I think it would be cool to do such a thing.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by daywalker1970, Today, 04:44 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post daywalker1970  
                              Started by kaywai, Today, 02:40 PM
                              0 responses
                              18 views
                              0 likes
                              Last Post kaywai
                              by kaywai
                               
                              Started by Angus7, Today, 06:03 AM
                              2 responses
                              51 views
                              0 likes
                              Last Post Angus7
                              by Angus7
                               
                              Started by Rhoamajhunm, Today, 05:15 AM
                              0 responses
                              31 views
                              0 likes
                              Last Post Rhoamajhunm  
                              Started by cannaleafzcoast, Yesterday, 11:46 PM
                              0 responses
                              21 views
                              0 likes
                              Last Post cannaleafzcoast  
                              Working...
                              X