Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

historical bars

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

    historical bars

    Hello, I am testing a strategy from the Strategies tab, the datafeed is from zen-fire. The bar size is 1 minute, I keep track of the bar times printing them to the output window. The position is closed at a fixed time, say at 15:00. I have removed the if(Historical) return block from OnBarUpdate().

    I start the strategy live at 14:00 and get the print of time bars beyond this time, up to 15:00, when the strategy shold stop. How can that be?

    #2
    Hi mdm72, if the strategy is still active and not stopped it will still call the OnBarUpdate() and you will see the times printed. Adding the time filter and trade exit time to your code will only stop the processing of orders and take your open trade flat.

    Comment


      #3
      My question concerns the fact that, when submitting live my strategy, the OnBarUpdate() runs over historical bars beyond the actual time displayed on my PC. It was 14:00 and got Time[0] for historical bars
      equal to 14:01, 14:02, 14:03, 14:04, and so on ...

      I closed NT and reconnected and this problem has gone away.

      Comment


        #4
        Please try to sync your PC clock and try this again, also consider NinjaTrader uses the closing time to stamp the bars, so for the 14:00 bar in progress the closing time would 14:01 on a 1 min chart. Thanks!

        Comment


          #5
          I have attached a test strategy to illustrate the problem. If I run this LiveTest on ES 03-06 I create a file for each bar on the directory C:\scratch; in my time zone (Central European Time) the program creates files from Bar00000.txt to Bar233000.txt, and my local time is 15:34 now. To what day do the Bar153500, Bar153600,... data refer to?
          In other terms, if I run the strategy on real time data (Simulation Trade), I get approx 24 hours of bars, with a timestamp which in the future with respect to my actual time, and this causes some problems. Thanks.
          Attached Files

          Comment


            #6
            Hi, thanks I will take a look at your strategy - meanwhile please try this simple snippet in the strategy OnBarUpdate() with CalcuateOnBarClose set to true -
            Code:
            [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] OnBarUpdate()
            {
            Print(CurrentBar [SIZE=2][SIZE=2]+ [/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] + T[/SIZE][/SIZE]ime[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]].ToString());
            }
            [/SIZE][/SIZE]
            Then you see the historical time stamps as well as the current one in the output window, provided your time on the PC is synched correctly.

            Comment


              #7
              Another way for me to solve this issue is to understand the following: when I start a strategy from the strategies tab, a number of historical bars (I use minutes) is loaded: how is this number of bars set? Thanks.

              Comment


                #8
                Hi mdm72, you can set the days loaded under Tools > Options > Data > Chart default lookback.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                582 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                338 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 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
                552 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X