Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with work with TWS and strategy. Freeze on work

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

    Problem with work with TWS and strategy. Freeze on work

    Good afternoon.
    We are currently testing the strategy on TWS Stocks. And we are faced with a problem that we cannot diagnose. We have two cases, but they all boil down to the same effect.
    Description of case 1 - while working with the chart, the strategy works 95% well, but there is a moment when the Chart completely freezes and does not react to anything. It can only be closed by removing it from the processes.
    Description of case 2 - this case is easier to reproduce, the strategy is launched on several instruments (from 10 to 100) at the same time. The result can be obtained faster. The strategies window is active but the actual strategies do not work.
    Also, at this moment, no updated data is received from TWS (account status, position status). Also, the strategies themselves do not work, although they are shown to be active.

    As a result, what we were able to see from the logs and using Debug:
    1 - For unknown reasons, after processing orders from TWS, Ninja stops processing both strategies and any internal flows.
    2 - Ninja does not write anything to the log
    3 - Code management in strategies does not occur, by Debug we do not even enter the onBarUpdate method.

    But the strangest thing is that everything works fine on the simulation and does not cause any problems.

    Please tell me how to diagnose the problem and find the reasons for the freezing of ninja and strategies?

    Logs and screenshots are attached.​

    P.S. NT 8.0.28.0 64-bit and new TWS Build 10.23.2a, Jun 15, 2023 4:54:18 PM (version from manual)
    Fresh install Windows, NT and TWS. This error we have on any environment
    Attached Files

    #2
    Hello tanas.eduard,

    Thank you for your post.

    ​To test, does this behavior occur when only running 5 strategies simultaneously?

    If this still occurs we may then test further by test 1 strategy at a time attempting to replicate on a single Stock so that we may narrow down this behavior.

    Then once we are able to narrow down to 1 stock we may check the log for other errors mentioning the this stock instrument.

    Spencer F.NinjaTrader Customer Service

    Comment


      #3
      Hello,
      Thank you for your prompt response and valuable guidance. I would like to share additional details about the problem that may help to better understand and solve this complexity.
      1. The problem we are facing is random. It can occur both when using a limited number of strategies (for example, 1, 2), and when working with a larger number of them (5, 50, etc.). However, it should be noted that when working with a small number of strategies, the problem is very difficult to diagnose. In the case of a larger number of strategies, it manifests itself more quickly and clearly.
      2. It is important to note that this problem is observed only when working with TWS. It does not appear during the simulation, which may indicate some specific interactions between TWS and NT. As far as we could understand from the trace, this is due to the processing of orders from TWS and the Ninja processes crash and freeze, since TWS and its API work perfectly at this moment (we checked).
      3. The inclusion of the Debug mode allowed us to note that the execution of our strategies is frozen and no information is transmitted to them (there is no input to the onBarUpdate, onOrderUpdate and others methods). Also, logging was added to the strategy code to track any events. From the logs, we can conclude that the strategies just freeze and do not receive the necessary quotes and events from Ninja.
      4. From the analysis of the trace file (Trace) in Ninja, it is clear that he also faces a similar situation. The logging process simply stops running, and, accordingly, the entire system freezes.
      Given this new data, it seems that the root of the problem may be related to the interaction between NT and the TWS API, as well as the influence of a large number of policies on this process.
      We continue to carefully analyze this situation, and your cooperation in finding a solution is very valuable. We will take additional steps to identify the exact causes that may lead to this issue. If you have any ideas on how to diagnose and solve the problem, we will be grateful.​

      Comment


        #4
        Hello tanas.eduard,

        Thank you for your post.

        Other items you may test is reducing the Days to Load on your Charts to 1-2 days as you may be hitting the Historical Data Limitation put in place by Interactive Brokers.

        You may also try disabling the option 'Get data from server' from the Tools > Options > Market Data window.

        Spencer F.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        77 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        45 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        27 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        32 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        62 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X