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

AddOn BarsRequest OnBarUpdate

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

    AddOn BarsRequest OnBarUpdate

    In an AddOn, I have multiple BarsRequest objects and a single OnBarUpdate method to handle all updates to all of them.

    Works beautifully when starting the AddOn with a single, connected Connection (it happens to be the FREE NinjaTrader Forex data feed). As part of testing contingency code for various circumstances, I deliberately disconnect from that one Connection. No problem recognising the Connection has disappeared.

    I then reconnect the same Connection. The reconnection is detected (independently of OnBarUpdate) and OnBarUpdate seems to be being invoked again. However, within a few seconds, all updates stop completely -- not even a single invocation of OnBarUpdate. At no point is the BarsRequest.Update event explicitly changed, nor the actual BarsRequest objects themselves.

    The observations above come from the extensive tracing output I produce.

    Notably, charts with the same Instruments as for the BarsRequests update as expected after the reconnection, so the data flow is indeed restored.

    Questions:
    1. Is there any obvious reason why this might happen?
    2. Does a disconnect cause any form of implicit change to BarsRequest.Update events?
    3. Any recommended approaches to diagnose this?
    Most grateful for any insights or remedies.

    Thanks.

    [Codebase is 75K lines so no real opportunity to provide it, sorry. Complexity probably prevents a "simple" example too.]
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    From the given details I really couldn't say anything sticks out. I would likely suggest to try using the addon sample to see if you can reproduce the problem using that. You mentioned that nothing changed, that may also be the problem or that you need to make a new BarsRequest and re subscribed after the reconnect event. You could take a look at how the addon sample first unsubscribes and nulls the existing request if it exists, you would also need that type of logic when making a new request after the new connection.

    To address the question we would not want to look into your actual code because that would be complex and contain other items. Starting off with a small sample of your own or testing an existing reference sample would be the best place to start looking into the problem. If complexity prevents a simple example then you would need to debug your code to find what combination is causing that so you can try to form a simple sample containing those parts.

    Please let me know if I may be of additional assistance.







    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks, as always, Jesse, for your time and insights.

      I already have code to refresh market data by disposing and recreating specific BarsRequests when appropriate. I "solved" the matter by simply invoking that code after a reconnection. It now works ... but it would be good to understand why that would be needed.

      It raises a persistent matter of concern that any connection/reconnection of Accounts nearly always freezes NinjaTrader for several seconds. Even when my AddOn is not running, it is obvious that connecting usually causes a major performance hit for a short period of perhaps as much as 10-15 seconds or more, depending on the situation. This is something that I think should be investigated separately, and quite independently of the particular matter raised here.

      In these days of multi-threading and asynchronous tasks, it is surprising that a core activity such as this has so substantial an effect that it can even freeze multiple standard NinjaTrader windows. Grateful if you would look into this, Jesse. My sense is that the factors contributing to this may include the number of Accounts configured, the number of them that are connecting, where those Accounts are connecting to, etc. However, even a single connection on one Account can manifest the issue.

      An example that I have seen show the effects is to define a handful of simulation accounts and connect to a Connection. Try a variety of Connections too. The FREE NinjaTrader Forex connection can manifest this, but I'm in Australia, so there may be some contribution by virtue of network distance, although I don't believe it is so because if I connect to more local data feeds, the effect is still there. "Production" broker connections can be very slow, but even that aspect should be irrelevant. Waiting for any connection, regardless of how long it takes, should not "hang" other non-connection-dependent parts of the platform. Network speed itself is certainly not a problem, and even if it were, I don't believe it should manifest as frozen UI elements (e.g. Control Center, Editors, etc). [And by "frozen", I mean unresponsive, but more obviously, various window title bars become white along the top for a period.] And system performance is not an issue in my case, nor should it be in any case if "merely waiting" for a connection.

      Points for consideration include that connecting should not have any significant or noticeable effect on the UI in any respect other than a lack of data to drive data-driven UI activities (e.g. charts). I would not expect to see windows freezing and other threads freezing too (e.g. any real-time clock display "stops" for the duration).

      Thanks for looking into this, Jesse. It's something that can be investigated without a specific piece of code or one well-defined specific circumstance. NinjaTrader is such a superb piece of software engineering generally, so this behaviour presents a challenge that I would like not to have happening when I use it, nor to have to code to provide "comfort" to users of my software when it happens, and for users not to have to experience at all.

      Many thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        The re connection would be just another case where you would need to resubscribe, I am not sure there is anything additional to look into here if you solved the issue. The platform pausing can sometimes occur. When the terms multi-threading and asynchronous are being used that does not necessarily mean every part of the platform makes use of those items. Some code will be synchronous and you will see the platform need to wait on some tasks to complete before it can continue. You are also correct, this should be investigated separately from this post as this posts question relates to coding and not general platform performance. if you feel that there is something else to look into please feel free to post in the platform support sub forums to go over general performance tips.


        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks, Jesse. I've posted to the Platform Support forum: https://ninjatrader.com/support/foru...ormance-issues

          Appreciate your time and advice.

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          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
          5 views
          0 likes
          Last Post cls71
          by cls71
           
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          214 views
          1 like
          Last Post PaulMohn  
          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
          4 responses
          547 views
          0 likes
          Last Post PaulMohn  
          Started by GLFX005, Today, 03:23 AM
          0 responses
          3 views
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Working...
          X