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

Number of bars visible in chart window

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

    Number of bars visible in chart window

    HI NT-8 people ..

    I have been looking for the code / variable that holds the number of bars visible in the current chart window ... is this possible ? I have found lots of info on chartbars, but thats all the bars loaded in the chart .. I just need the number of bars visible in the chart window, which could change if I expand or shrink the window etc ..

    Any help greatly appreciated as always


    #2
    Hello 12tkram,

    Thanks for your post.

    This would be possible by subtracting ChartBars.FromIndex from ChartBars.ToIndex in OnRender().

    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
        ClearOutputWindow();
        Print("Bars Visible: " + (ChartBars.ToIndex - ChartBars.FromIndex));
    }
    Please let me know if you have any questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      oooo, thats was quick .. brilliant, will give it a go!!!!!!!!!

      Comment


        #4
        yep, that works perfectly .. thanks again, awesome support as per usual!

        Comment


          #5
          weirdly though, when I add the OnRender() function all my EMA plots disappear? is that expected?

          Comment


            #6
            OnRender() is like a plot override. To also see your plots put this line at the beginning of the OnRender() method:
            base.OnRender(chartControl, chartScale);
            eDanny
            NinjaTrader Ecosystem Vendor - Integrity Traders

            Comment


              #7
              Thanks eDanny

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by AveryFlynn, Today, 04:57 AM
              0 responses
              3 views
              0 likes
              Last Post AveryFlynn  
              Started by RubenCazorla, 08-30-2022, 06:36 AM
              3 responses
              77 views
              0 likes
              Last Post PaulMohn  
              Started by f.saeidi, Yesterday, 12:14 PM
              9 responses
              23 views
              0 likes
              Last Post f.saeidi  
              Started by Tim-c, Today, 03:54 AM
              0 responses
              3 views
              0 likes
              Last Post Tim-c
              by Tim-c
               
              Started by FrancisMorro, Today, 03:24 AM
              0 responses
              5 views
              0 likes
              Last Post FrancisMorro  
              Working...
              X