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

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

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

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

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

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by moneyexe, Today, 11:22 AM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by stevec1824, Today, 11:00 AM
                2 responses
                5 views
                0 likes
                Last Post stevec1824  
                Started by sofortune, Today, 10:05 AM
                2 responses
                9 views
                0 likes
                Last Post sofortune  
                Started by sofortune, 05-10-2024, 10:28 AM
                6 responses
                46 views
                0 likes
                Last Post sofortune  
                Started by ETFVoyageur, Today, 08:54 AM
                3 responses
                31 views
                0 likes
                Last Post ETFVoyageur  
                Working...
                X