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

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.
      BertrandNinjaTrader Customer Service

      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.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Harry, 05-02-2018, 01:54 PM
                10 responses
                3,202 views
                0 likes
                Last Post tharton3  
                Started by cre8able, Yesterday, 01:16 PM
                3 responses
                11 views
                0 likes
                Last Post cre8able  
                Started by ChartTourist, Today, 08:22 AM
                0 responses
                6 views
                0 likes
                Last Post ChartTourist  
                Started by LiamTwine, Today, 08:10 AM
                0 responses
                2 views
                0 likes
                Last Post LiamTwine  
                Started by Balage0922, Today, 07:38 AM
                0 responses
                5 views
                0 likes
                Last Post Balage0922  
                Working...
                X