Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Thread safety

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

    Thread safety

    Hi,
    I am converting an NT 7 strategy to NT8 and I'm running into some issues that I suspect may be thread related. I have a series of module level variables defined in my strat's class. When I run the optimizer and set breakpoints in OnExecutionUpdate, I notice that it is called > 1 time WHILE I am still in the routine from the first call. This did not happen in NT7. I am not an expert on multithreading and thread safety. Is there something different I should be doing with module level variables in NT8? Am I right that module level variables are being stomped on? Are there guidelines, things I need to do differently as a result of the multithreadedness of NT8?

    On a separate note. I've noticed that the optimizer just crawls when I am debugging using vstudio. Changing a parameter in the optimizer takes minutes!

    Any help on this would be greatly appreciated.
    Thanks ... Ed

    #2
    Executions/Orders/Position now receive the core update event, which means it is possible to receive multiple updates on different threads. This is a result of exposing the core update events rather than the previous NinjaTrader 7 interfaces.

    How you handle ultimately depends on the type of variables you're using and how they're being updated. If you were using a collection for example, you could use a ConcurrentDictionary which can be accessed by multiple threads at once.

    You can also simply use a Lock to ensure that access to whatever block of code you're executing is only being accessed by one thread at a time.

    We do not not have any best practices or tips at this time, but we do plan on building up our documentation in this area once we better understand the common issues user run into due to the new multithreaded framework and the suggested solutions based on those problems. If you're new to threading, one of our developers recommend the following 3rd party article on this topic:

    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DJ888, Today, 10:57 PM
    0 responses
    1 view
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Today, 09:29 PM
    0 responses
    7 views
    0 likes
    Last Post Belfortbucks  
    Started by zstheorist, Today, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    151 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Working...
    X