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

currentbar resets

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

    currentbar resets

    I am new to developing an indicator and am trying to the currentbar value within my onbarupdate method. I notice though that it goes well beyond 1000 but when I get to a realtime state it ends up being in the lower hundreds, around 200. Why does that happen?

    #2
    Hello hansob3,

    Thanks for opening the thread.

    I am not sure how you are testing to see the behavior you are describing. CurrentBar will start at 0 for the first historical bar and will continue increment even after the script has transitioned into realtime bars. I have attached a video explaining the behavior: https://www.screencast.com/t/IezPWUzQZvE

    Historical bars will always calculate with Calculate.OnBarClose unless Tick Replay is enabled on the Data Series and the NinjaScript is set to Calculate.OnEachTick. Realtime bars will calculate either on bar closed or with each tick depending only on the Calculate setting.

    I'd like you to take the same steps I have in my video to see the behavior.

    Calculate - https://ninjatrader.com/support/help...?calculate.htm

    CurrentBar - https://ninjatrader.com/support/help...currentbar.htm

    If you have any questions, please don't hesitate to ask.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply.

      I did your tests and I see how they work. What happens if using tick replay and update bar on every tick?

      Comment


        #4
        Hello hansob3,

        Each bar, historical or realtime, will update with each tick if Tick Replay is enabled and Calculate is set to On Each Tick. Simply put: Tick Replay will allow historical bars to build with each tick.

        Please let us know if we can be of further help.
        JimNinjaTrader Customer Service

        Comment


          #5
          Take a look at the attached images and code. Am I missing something?
          Attached Files

          Comment


            #6
            Hello hansob3,

            I would not expect the data to output that way.

            I may suggest an Instrument Reset.
            1. First, disconnect from any data providers by navigating to the Control Center > Connections menu, and left-click on “disconnect” that appears to the right when hovering your mouse over any active connection
            2. Next, reset your instruments by navigating to the Control Center > Tools > Database Management
            3. In the Database Management window, under the “Update instruments” section, ensure that “General properties”, "Futures expiries" and “Symbol mappings” options are checked and then click Update
            4. Lastly, restart NinjaTrader for the changes to occur


            If this does not resolve your inquiry, could you reach out to me at platformsupport [at] ninjatrader [dot] com with the ticket ID "1856413" and the text "ATTN Jim?"

            I look forward to looking into this further with you.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by yertle, Today, 08:38 AM
            6 responses
            24 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            24 views
            0 likes
            Last Post algospoke  
            Started by ghoul, Today, 06:02 PM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            46 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            23 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X