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

How to load chart asynchronously?

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

    How to load chart asynchronously?

    Typically, when we open a tick chart, i.e. 2 days. I see the connection (whatever broker, doesnt matter) takes much time i.e. on each call, provider returns 500/1000 items (bars) and for i.e. 3-4 days chart, it needs to re-qeury its server i.e. 10 times (or more maybe, who knows). During all these time, chart is frozen (loading) till all bars are obtained.

    So, my question, is there any way (there might be, but NT technicians will know that) to force chart to show those bars on chart on-the-fly, that has been obtained and in the background it will of course continue querying other bars.
    Like Tradingview charts do, they load parts of bars on-the-fly bucket-per-bucket, thus user doesnt have to wait for all chart to be shown once.

    I assume there might be some way (i.e. from addon, set some internal NT parameter of BarsRequests object to allow that)...
    Last edited by ttodua; 07-10-2021, 11:08 AM.

    #2
    Minute and Day based charts should already be super quick.

    But charts based upon certain BarTypes, such as Range, Renko,
    Tick, as well as Volume charts, would probably be near impossible
    to do what you suggest.

    TradingView is a fundamentally different product, and since it is
    server based, they can cache a LOT of things, including bars.

    Just my 2˘.

    Comment


      #3
      Thanks bltdavid for response.
      Minute/Dailies might be fast, yeah, but the reason of this topic is tick-based charts, which (in one day) might have 50 000 items. So, to add another 2 cents, I don't think it will depend on product if it's server-based or desktop-based program, and neither it depends on caching, but what I say is that, when the Broker's adapter calls for tick-data (with it's BarsRequest method) and gets (i.e. 1000 items per call, and it has to make 50 calls before it allows chart to be shown), i assume it will be quite possible that when first bucket arrives, they were shown on chart, and the-chart was being filled with additional bars as the progress of queries goes on. this doesn't have any dependency on caching mechanism, just the asynchronous approach of chart-loading.

      Comment


        #4
        I doubt the callback `RequestBars(Bars, Action<IBars b2, ErrorCode e2, string m2>, string)` method (which are called by NT Adapter loader base, probably by NinjaTrader.Data.BarsSeries class or alike) has the imperfection, because (I have tested myself) for example, if adapter makes 30 requests (to get needed data for user's chosen chart), that callback is meant by NT to be called only after all those 30 requests are done and all bars are obtained. If that callback is called after receiving each request (thus, not waiting all of those 30), then after first execution of that callback, next 29 executions of that callback are done in vain, as they don't add any new bars on chart (even data received and the same callback triggers to "fill the chart with bars"). so, that method needs to be fixed by NT to support smooth loading of charts(like TradingView does) and better User experience.

        Maybe someone from NT support might give any clues.
        Last edited by ttodua; 07-11-2021, 05:13 AM.

        Comment


          #5
          Hello ttodua,

          There is no supported way to control the backend of NinjaTrader loads data for charts.

          You can choose to preload the data in the Tools -> Historical Data window.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            ...
            Please submit Feature Request for that. As addition, add this note:

            In adapter class, we could be able to use the interface method , named `RequestBars` like this:


            HTML Code:
            public void RequestBars(IBars bars, Action<IBars, ErrorCode, string> callback, IProgress progress)
            {
                 List<> FinalBarsArray = ...;
                 for(var i=0; i<..; i++)
                 {
                       var data = api_func_get_ticks(...);
                       FinalBarsArray.Add(data);
                       ....
                       callback(bars, ErrorCode.NoError, string.Empty);   // <---------------  we should be able to call it here, at this moment, this does not work, because if we call it here, the next iterations of the loop will be in vain, as the "callback" ends the loading-of the chart, after which no bars are added, even if this command will be executed again
                 }
            
                 callback(bars, ErrorCode.NoError, string.Empty);   // At this moment, we have to call it here, otherwise, as commented above, it doesn't work
            }

            Comment


              #7
              Hello ttodua,

              I will submit a feature request on your behalf to control how charts load data.

              Once I have a tracking ID for this request I will post this in this thread.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hello ttodua,

                Thank you for your patience.

                Chelsea is out of the office today, however, we have created a new feature request for this on your behalf. This request is being tracked under the number SFT-5292.

                As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

                Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

                Please let us know if we may be of further assistance to you.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by ttodua View Post

                  Like Tradingview charts do, they load parts of bars on-the-fly bucket-per-bucket, thus user doesn't have to wait for all chart to be shown once.
                  Seems to me that NT8 executes this functionality now when the bars are already in your local bar cache ../NinjaTrader 8/cache

                  While waiting on that feature request to get built might try....

                  1) Create a workspace you will always leave open that has tiny charts open with a few of your favorite symbols and timeframes and ZERO indicators or ChartTrader windows open. Always have this open in the background but mostly forget about it. It might load your cache with bars giving the effect you want to see..( you see the latest bars fast but still can not access the chart until they all fully load).

                  2). See if the existing BarsRequest will load the bars cache for you.


                  Best Practice to Improve NT8 Usability, Felt Performance.

                  3) Personally, I a little bit already have that TradingView functionality. At end of day I switch to a very thin workspace titled "Key Symbols Loader" and close all other workspaces before logging off. This workspace has ~15 key symbols each in a few key time frames and BarTypes. These charts are all very small in size and have zero indicators.

                  When NT8 boots up in the morning it preloads the local cache with the majority of the bars I will ask for that day. About a minute after boot up I switch to another workspace and close this one. Overall my client boots into my primary workspace faster and consuming less memory than if I just booted into my primary Workspace directly. Additionally, through the day a good percentage of my charts load faster than if I had skipped executing this practice that day.

                  Note that always keeping open a Market Analyzer Window with a list of your favorite instruments might also help keep some of cache current through the day, but with less coverage than than the thin ""Key Symbols Loader" workspace I describe above.

                  HedgePlay
                  Last edited by hedgeplay; 07-25-2021, 11:17 AM.

                  Comment


                    #10
                    Originally posted by hedgeplay View Post
                    ...
                    Thanks for nice idea !
                    however, you know , "tricky workarounds as a solution" can be used as a workaround literally, thus asynchronous load (if it will be implemented) will make things natively performant and easy-to-use.

                    Comment


                      #11
                      "2). See if the existing BarsRequest method will load the bars cache for you"

                      Have you tried this one.. Will this load the local bars cache and give you some of the most-recent-bars Chart presentation speed you seek?

                      I would be interested to know.

                      HedgePlay

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Aviram Y, Today, 05:29 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post Aviram Y  
                      Started by quantismo, 04-17-2024, 05:13 PM
                      3 responses
                      25 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by ScottWalsh, 04-16-2024, 04:29 PM
                      7 responses
                      34 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by cls71, Today, 04:45 AM
                      0 responses
                      6 views
                      0 likes
                      Last Post cls71
                      by cls71
                       
                      Started by mjairg, 07-20-2023, 11:57 PM
                      3 responses
                      218 views
                      1 like
                      Last Post PaulMohn  
                      Working...
                      X