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

Retrieving future/next bars' data from the currently processed bar

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

    Retrieving future/next bars' data from the currently processed bar

    I know this question has been asked before more than once. I know I can't use barsAgo[-1] to retrieve the next bar's info. I figure, unless I'm overlooking something, there is no supported way to access future bars from the currently processed bar, in neither NT 7 nor 8, and I simply don't get it. The data is there. It's just not available to the code for whatever reason. Something that can be done on other platforms, can be done with Excel, can't be done with NT. You essentially force all indicators to look only to the past and never to the future. That is one disappointing limitation.

    Simply put, there should be BarsAhead similar to BarsAgo.

    If there is any workaround, maybe going into the low level API/.Net, I'd be happy to know. Or if I'm overlooking something obvious, I'd be more than happy to eat my sombrero.

    Thanks.

    #2
    Hello digibob,

    Welcome to the NinjaTrader forums.

    This would be the equivalent of calling your broker and asking what the price of a stock will be in 10 minutes.
    NinjaTrader is not designed to access the future. Only the current prices and the past, the same as a trader would in real-life over the phone.
    A script is also designed to work through historical data with the same rules as processing real-time data.

    I will submit a feature request on your behalf for the development team to consider support for accessing future bars in historical data.
    Once I have a tracking ID for this I will post in this thread for future reference.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea. Thanks for your answer.

      There are uses and applications for looking both ways, backward and forward. It may be true that as we get near the latest most recent bars on the chart there is a degree of inaccuracy, but this can be redundant/negligible depending on what the application is.

      A car has lights both in the front and in the back, if talking about real life. When I look at a chart and examine a historical bar with my own eyes, I also see what happened later on the chart. I have the 'full context' of that bar. So should the code.

      Since this is not a philosophical matter but a technical one, there is no reason why the code should not know what my eyes know. The data is already there.

      I appreciate your answer though. Looking forward to seeing this implemented in a future version of NT.

      Meanwhile I will have to find a solution for the present time and hopefully someone will still have an idea of how, somehow, nonetheless, I can get hold of this data that *is* there.

      Comment


        #4
        Hello digibob,

        Using the car analogy, looking at something in-front of you and making projected calculations is not the same as foretelling the future.

        As an example, you can see the road and see there may be an obstacle based on the speed you are going and based on the size of the current view of the object (which would be similar to making an indicator that uses the currently processed data to calculate the upcoming trend of the market). However, there would no way of knowing that object will suddenly take an abrupt left turn. Imagine you were headed straight and then a car headed the opposite direction suddenly swerved into your oncoming lane of traffic exactly .00001 seconds before they reach you. When that car was still 1 minute away, are you able to predict that at .00001 seconds before they reach you they will suddenly swerve into your lane of traffic?

        Looking out of a window is not the same as being able to predict the future.


        The point is, is that in real-time, no, there is absolutely no way to predict what the price of the next tick from the market will be.
        OnBarUpdate is not processed differently in historical data than it is in real-time and works with the same rules.

        If you want to do a bars request and get some out of sync data (even if its historical data that is at a later date or time than the historical data that is currently being processed) and loop through it, that is fine to do.


        If you want write some data out to file and loop through it, that is also fine to do.



        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea.

          Using the car analogy, imagine there was only a mirror (back) view and no front view. As simple as that. How would the car go.

          That analogy may have been misplaced or not properly explained. It was just showing "things" in life with front and back views, as opposed to NinjaScript which is 'forward-blind'. It unnecessarily treats historical bars as live bars. If we know how many bars are in total on the chart and we know the currently processed bar is not the live one, why not have the rest of the bars' data available. It *is* available to the eyes. The code is in a disadvantage to the eyes.

          For example a normal size bearish looking bar with exceptionally high volume. When it is live I would probably deem that bar selling pressure. But if from there on the price just goes up and up with convincing volume, I then know that bar was actually buying pressure in disguise of selling pressure. "Smart money" was absorbing the panic selling of "dumb money". This is wisdom I have in retrospect. It is valuable when analyzing the chart as a whole, and this 'retrospect' should be available to the code in 'live' analyzing of historical bars. I will say again and again, the data is there.

          Another example, the Swing indicator has to proceed to the next bar before it can draw a line to the prior bar as being the high or the low. That is a limitation. If this is a historical bar, why not draw the line right away while processing that bar. The data of the next bar is there. It is just hidden from the current bar in the name of some philosophy.

          As for the links provided, they look interesting at first glance, not sure if that is the workaround I was looking for, but something is better than nothing. I will delve into them.

          With future versions in mind, I just hope NT doesn't consider these links a proper solution to the limitation described. Solution should be easy and straightforward, part of the normal NinjaScript flow of code.

          Having said that, thank you so much for your help. Greatly appreciated!

          Comment


            #6
            Hello digibob,

            If there is no front window, the car is not processing any information. The car would not be able move. In the same way, the script would not be able to run in real-time and would not function at all and could not be used at all.

            Is it clear how the scripts are working in real-time and cannot predict what the next tick will be until its received?

            Is it clear that NinjaTrader does not process data differently in real-time than with historical data? (So scripts don't have to be programmed differently for a backtest than being run in real-time.)

            What I have put in a feature request for you for is to treat historical data differently than real-time. The request is to allow future bars to be accessed. Have I mis-understood your request? Would you like for me to modify this request?


            A BarsRequest is intended for calling data out of sync for any purposes other than what a series is intended for in an indicator. It is absolutely not intended at this time to be able to predict the future either in real-time or historical.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello digibob,

              I have received tracking ID# SFT-3939 for this request to support calling future bars.

              Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.

              Thank you for your request.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hi Chelsea.

                Thanks for the feature request. Yes, you have understood correctly. Just to clarify this is not intended only for backtesting, also for live trading, the ability to analyze a chart in real-time, where the most recent bar is 'forward-blind' naturally, but all the other bars have a forward view. Similar to human eyes analyzing the chart.

                The BarsRequest is out of sync, as you said, would make me rewrite everything I did so far, and somewhat defeat the purpose of using NinjaScript, even though it is a NT feature. It is not completely irrelevant to my case. I call it 'plan B' for now, still looking for plan A...

                Thanks again for your kind response and help.

                Comment


                  #9
                  Hello digibob,

                  Where you have mentioned:

                  "Just to clarify this is not intended only for backtesting, also for live trading, the ability to analyze a chart in real-time, where the most recent bar is 'forward-blind' naturally, but all the other bars have a forward view."

                  I'm not quite understanding your meaning. You can process each tick as it is received in real-time. NinjaTrader is not able to predict what future ticks are.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Chelsea.

                    Wouldn't that be something if NT could predict future ticks

                    What I meant was, today Apr. 11, once trading starts, that's the live bar. Let's say I am then loading the daily chart of a certain symbol, some indicators on the chart. While OnBarUpdate is processed for the Apr. 8 bar, I want to be able to access the data of the Apr. 9 bar. That's it.

                    Comment


                      #11
                      Hi Chelsea.

                      I'm humbled, embarrassed, eating my sombrero and it's actually yummy, because -

                      Bars.GetClose(int index)
                      Bars.GetOpen, Bars.GetVolume, etc.

                      That's all I ever looked for.

                      I don't see these calls in the NT7 documentation under Bars object. I do see them in the NT8 documentation.

                      My sincere apologies for confusing you with some vague and pompous words (English is not my native tongue) and for not exploring further before raising the question.

                      My gratitude once more for your help and also your patience!

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bill2023, Yesterday, 08:51 AM
                      8 responses
                      43 views
                      0 likes
                      Last Post bill2023  
                      Started by yertle, Today, 08:38 AM
                      6 responses
                      25 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
                      16 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  
                      Working...
                      X