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

Last bar on the visible chart

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

    Last bar on the visible chart

    Apologies if this answer exists in the documentation (I looked but couldn't find what I was looking for).

    Is there code that will let me find the last 'visible' bar at the far left edge on a chart?
    (preferably code that gives me number-of-bars back from CurrentBar).


    Thanks.....

    #2
    Hello photog53,

    Unfortunately there isn't a supported property for this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      ....I thought that might be the answer.

      Thanks for the quick response....

      ...(what I wanted to do, was code an indicator that kept my charts "in scale" visually....
      When price narrows, Ninja charts expand top-to-bottom and the visual relative size
      of the candles becomes misleading. In those circumstances, a 30 tick 6E channel
      looks as large as the prior 70tick swing.
      If I could plot the last visual bar, then a simple MAX/MIN lookback would let me plot
      the range of the visible chart, and then load an AutoScale=true text, line, (or whatever)
      at a configurable % above high or below low, which would add whitespace top/bottom
      and maintain the desired visual scale.
      The indicator would then remove it's plot when price moved back into a larger range.)

      I can sort-of do the same thing with a fixed lookback period, but that doesn't keep up if
      I change the window size.

      Thanks again.....

      Comment


        #4
        Thanks for sharing the details of your project. Hopefully other community members with experience in this area can assist.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I've already coded the indicator, and it works very well. The only issue is that without ability to internally find the 'left edge", the Lookback needs occasional adjustment from chart to chart, or when I adjust window size.....
          I can set the chart 'scale' in ticks to a size that is visually representative
          of price swing, adding white space top and bottom when price narrows...
          and it will reset itself automatically when price resumes a larger price swing.

          I may post it on the forum for others.....

          Comment


            #6
            Hi,

            did you ever find a solution for this?

            EDIT: sorry, completely misread the title: I thought it said right-edge.

            That's what I'm looking for - an alternative to CurrentBar that tells me which bar is at the right hand edge of the visible chart.

            Does that exist in NT7?
            Last edited by adamus; 03-02-2012, 06:56 AM.

            Comment


              #7
              Originally posted by adamus View Post
              Hi,

              did you ever find a solution for this?

              EDIT: sorry, completely misread the title: I thought it said right-edge.

              That's what I'm looking for - an alternative to CurrentBar that tells me which bar is at the right hand edge of the visible chart.

              Does that exist in NT7?
              ref: http://www.ninjatrader.com/support/f...61631#poststop

              Comment


                #8
                That's exactly what I wanted.

                PHP Code:
                CurrentBar this.LastBarIndexPainted 
                Thank you.

                The OP here should probably experiment with this.FirstBarIndexPainted

                Comment


                  #9
                  Newb question: What does the "this" refer to? I'm trying to adjust my custome indicator to use the last displayed bar instead of current bar but the compile doesn't like the "this" in:

                  int intLastBarPaintedOnChart = this.LastBarIndexPainted;

                  Comment


                    #10
                    Originally posted by stockgoblin View Post
                    Newb question: What does the "this" refer to? I'm trying to adjust my custome indicator to use the last displayed bar instead of current bar but the compile doesn't like the "this" in:

                    int intLastBarPaintedOnChart = this.LastBarIndexPainted;
                    "this" refers to the current instance of the running indicator.

                    What is the error message that you are getting?

                    Comment


                      #11
                      I got it! I was just being too fancy with declaring variables when "this.LastBarIndexPainted" works just fine all by itself. Thank-you for this insight. It makes my custom indicator so much better!!!

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by cmtjoancolmenero, Yesterday, 03:58 PM
                      9 responses
                      35 views
                      0 likes
                      Last Post cmtjoancolmenero  
                      Started by DayTradingDEMON, Today, 09:28 AM
                      4 responses
                      23 views
                      0 likes
                      Last Post DayTradingDEMON  
                      Started by geddyisodin, Yesterday, 05:20 AM
                      9 responses
                      50 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by George21, Today, 10:07 AM
                      1 response
                      15 views
                      0 likes
                      Last Post NinjaTrader_ChristopherJ  
                      Started by Stanfillirenfro, Today, 07:23 AM
                      9 responses
                      24 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X