• 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

Chart questions

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

    Chart questions

    Hello Support --

    I have to question regarding NT charts.

    1. How to determine quantity of bars visible on a chart, not loaded. What are the methods to do it.

    2. How to shift visible part of a chart to the specific bar. If the bar is on the right and not visible on screen I'd like to shift the chart panel so it can be seen on screen. What are the methods to do it.

    Regards.

    #2
    Hello alex_bbfg,

    Thank you for your post.

    1. Count returns the number of bars: http://ninjatrader.com/support/helpGuides/nt7/count.htm
    CurrentBar returns the current bar being processed: http://ninjatrader.com/support/helpG...currentbar.htm
    So Count - CurrentBar.

    2. This could not be done in code and must be done manually by left clicking the Arrow button (looks like an old VCR pause/play button) on the top right hand corner of the Chart display area.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Hello PatrickH,

      Thank you for the reply.

      I tried your idea in the following code
      protected override void OnBarUpdate()
      {
      int br = Count - CurrentBar;
      DrawTextFixed("text", Count.ToString() +" "+ CurrentBar.ToString()+" " + br.ToString(), TextPosition.BottomRight);
      }

      and it gives me the following on the screens.
      It always show me the "2". My aim is to determine how many bars on screens and calculate their ATR. So I expect that each time I will move the chart panel my output will be change.

      Please, clarify if I misunderstood your idea.

      Regards.
      Attached Files

      Comment


        #4
        alex_bbfg,

        I think it is me that misunderstood you. So you want an ATR for example that uses the period as the number of bars visible in the chart display? Is this correct?
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          PatrickH,

          YES, this is correct.
          My english is not good, so I might write something wrong.

          Regards.

          Comment


            #6
            alex_bbfg,

            Adjusting the period of an indicator based on the number of visible bars would not be supported. It very well may be possible in NinjaTrader 7. If possible in NinjaTrader 8 it would require the ChartControl and ChartPanel: http://ninjatrader.com/support/helpG...n-us/chart.htm
            Last edited by NinjaTrader_PatrickH; 01-26-2016, 11:28 AM.
            Patrick H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by alex_bbfg View Post
              PatrickH,

              YES, this is correct.
              My english is not good, so I might write something wrong.

              Regards.
              Determining the number of bars showing on the chart is not impossible, albeit unsupported.

              ref: http://ninjatrader.com/support/forum...83&postcount=5

              However, your requirement is imprecise, and does not describe exactly what you want to do? One question would be: Is this fully dynamic, in which case widening or reducing the chart display will cause a recalculation of everything, or is everything to be calculated based on the original dimensions of the chart at startup? The latter, for example, would mean that you have to arrange to restart your ATR indicator if the chart dimensions change.

              Comment


                #8
                Hello koganam,

                thank you for the help.

                I've found

                ChartControl.FirstTimePainted;
                ChartControl.LastTimePainted;

                in NT8.

                My aim to have an indicator similar to bar on a chart at the top right corner of a chart which shows me the range of bars drawn on a chart with the tick value. Somethin like on the image below. It will help me visually evaluate the volatility.

                I used you code for test, but I've just put it inside OnBarUpdate() method and it changed value only when I changed the time frame of the chart.

                I'd like to recalculate my indicator while scrolling the chart panel resizing the chart. Each time when bars drawn on a chart changes.

                If you have any ideas when to call the recalculation of my indicator, please help.

                Regards.
                Attached Files

                Comment


                  #9
                  Originally posted by alex_bbfg View Post
                  Hello koganam,

                  thank you for the help.

                  I've found

                  ChartControl.FirstTimePainted;
                  ChartControl.LastTimePainted;

                  in NT8.

                  My aim to have an indicator similar to bar on a chart at the top right corner of a chart which shows me the range of bars drawn on a chart with the tick value. Somethin like on the image below. It will help me visually evaluate the volatility.

                  I used you code for test, but I've just put it inside OnBarUpdate() method and it changed value only when I changed the time frame of the chart.

                  I'd like to recalculate my indicator while scrolling the chart panel resizing the chart. Each time when bars drawn on a chart changes.

                  If you have any ideas when to call the recalculation of my indicator, please help.

                  Regards.
                  It would be hard to say offhand, but if you want to see past values, then you should be assigning to a Plot and printing the value of the Plot on the chart. That way, when you scroll the chart, the value you see is always the value that existed on the last bar visible.

                  As far as changing the size of the chart, there is a problem in the way that the ATR indicator is calculated. It really does assume a fixed lookback period, and because of how it is calculated, that means that you cannot dynamically change the lookback period. Is it possible to recode an ATR to properly use a dynamic period? Of course. It just has to be written.

                  However, if you are just scrolling the chart and not resizing it, then the number of bars eventually stabilizes. If using the current ATR indicator, you would just have to arrange to start calculating the ATR only after the count stabilizes.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by mohdhm, Today, 04:37 PM
                  1 response
                  17 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by trader14, Yesterday, 08:23 PM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by bigsurftrader, 02-24-2017, 12:23 AM
                  4 responses
                  1,162 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by svadukia, Yesterday, 01:56 AM
                  2 responses
                  25 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by quantrob, Today, 10:24 AM
                  1 response
                  7 views
                  0 likes
                  Last Post bltdavid  
                  Working...
                  X