Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Right Most Bar on Chart

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

    Right Most Bar on Chart

    Hi, is there a way to get the bar index of the right most bar currently displayed on my chart?

    ie, I have scrolled my chart to the right so that the current bar is no longer displayed.

    Thanks.

    #2
    Originally posted by dontpanic View Post
    Hi, is there a way to get the bar index of the right most bar currently displayed on my chart?

    ie, I have scrolled my chart to the right so that the current bar is no longer displayed.

    Thanks.
    My answer: http://www.ninjatrader.com/support/f...d.php?p=261631
    in this thread: http://www.ninjatrader.com/support/f...d.php?p=261544

    Comment


      #3
      Thanks for pointing him to this thread koganam.

      dontpanic, in our official NinjaScript there would be no means to get this info, however in the thread cited there was undocumented approach shared you should find useful.

      Comment


        #4
        Hi and thanks for that reply. I havent had a chance to test it yet, I got sidetracked on another related issue.

        I'm trying to add a timer into my indicator to fire an event every second. I downloaded and followed the code submitted by Yaris for BackTestBarData.cs which seems to be exactly the same as the code I have already written.

        However my timer event seems to not be triggered. I saw on some other posts that people were trying to create timers and that the timer elapsed event seems to depend on the OnBarUpdate() method being called. Im using this timer for backtesting, on the weekend, so there is no incoming data and hence no call to onbarupdate.

        One difference I noticed with Yaris code for timer was that the elapsed event was not declared static; most of the examples submitted that I found from google had declared it static, but this causes compile problems in NT which I havent resolved.

        Does anyone have a timer example working that does not depend on OnBarUpdate() ?

        Thanks.

        Comment


          #5
          sorry, ignore the timer issue please, there was an error in my initialise() that was preventing it from working.

          Comment


            #6
            I'm just trying to test the last bar index, and the value is 0. But also, I tested Count (the internal variable) and that value is -1, as if it has not been initialised yet.

            I'm working on the weekend and there are no OnBarUpdate() events happening so I am wondering if Count is initialised on the first OnBarUpdate() call?

            If so, is there any way to ensure that these values are correct?

            Thanks.

            Comment


              #7
              I figured this out, I didnt actually have my indicator loaded (in the list of indicators) for my chart.

              I was however getting output from the initialise() method, which is why I thought it was loaded.

              I'm still trying to understand how my indicator is compiled into the .dll and that my Initialise() function would be called but not the OnBarUpdate().

              Can anyone shed some light on this?

              Thanks.

              Comment


                #8
                dontpanic, the Initialize() would always be called across all scripts from each category so indicator or strategy, meaning if would not depend on the script actually being applied or not, but opening for example the indicator dialog box up would trigger a call to it. OnBarUpdate() in contrast is only processed on a bars update (historic or realtime) and for that the specific study had to be instantiated and running. Further please keep in mind we do everything event based, so the opening tick of a new bar is the closing of the currently open one, if you dont see an update / trade from a potentially not as liquid market it could be that a bar stays therefore open for a bit and you dont see new bars generated - as no trades occur inside the timestamp range of the new bar.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                579 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                334 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                554 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X