Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market Analyzer window -- cpu thread allocation

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

    Market Analyzer window -- cpu thread allocation

    I’m updating my trading computer and have some questions about how NinjaTrader 8 utilizes cpu cores when using a Market Analyzer window.

    Many posts on the forum mention that each instrument is assigned to a thread.

    Is this also the case in a Market Analyzer window, or due to the fact that a Market Analyzer window could contain many hundreds of instruments, is thread allocation handled differently?

    I primarily use the Market Analyzer after hours as an EOD screener, relying on historical data stored in the db files. I have a list of approximately 200 stocks that I scan using a custom indicator on a Market Analyzer column. During the trading session with a live feed, I typically have about 10-20 stocks showing in the Market Analyzer, with a single column showing the value of a custom indicator.

    When NinjaTrader is used without an active data feed (this is how I use it as an EOD screener) is thread allocation handled any differently than with an active feed?

    #2
    Hello h1000,

    Thank you for your note.

    NinjaTrader spawns multiple UI and instrument threads, it spawns them per the number of logical processor cores detected on startup.

    If you have 4 cores this means you'll have 4 UI threads and 4 instrument threads for a total of 8 threads.

    Once a market data subscription is started, it is assigned an instrument thread randomly and all processes which are driven from realtime data for that instrument will be on the same instrument thread moving forward. The instrument thread will then drive logic.

    The Thread pool is some action that is scheduled to execute something temporary in the background using a random thread which is not the instrument thread or the UI thread. We use these is some places in NinjaTrader. Most notably historical processing. This makes a difference in threading, as On Bar Update is called by different threads depending on what's occurring. So, in your particular use case, On Bar Update would be called by ThreadPool in historical processing, but the Instrument thread in real time processing.

    So yes, thread allocation would be different if you're using the most recent historical data vs. real time data coming in, but there would still be a thread used for each instrument.

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

    Comment


      #3
      Thread pools usually have a set number of threads always running (either already executing a task, or waiting for a task).

      When working only with historical data, how many threads does Ninjatrader create in the thread pool? Does Ninjatrader in any way limit the number of threads created when no data feed is being used? If Ninjatrader limits the number of threads created (when no feed is present) that would have a big impact on which processor would be best suited to my circumstances.

      I’d like to get some clarification on the following mentioned in your reply

      Originally posted by NinjaTrader_Kate View Post
      On Bar Update would be called by ThreadPool in historical processing, but the Instrument thread in real time processing.
      If I understand correctly, with real time data, each instrument in the Market Analyzer would be assigned to a thread and that thread would call OnBarUpdate. However, with historical data, each instrument in the Market Analyzer is randomly assigned a thread in the thread pool, which then calls OnBarUpdate. In either case, the outcome is no different in that one instrument is assigned per thread. Is this correct?
      Last edited by h1000; 03-03-2022, 11:54 AM.

      Comment


        #4
        Hello h1000,

        Thank you for your reply.

        I've discussed this with my lead, and we are not sure "how many" threads are created in the thread pool, but would expect it to be relative to the number of logical cores.

        You could check the properties of System.Threading.Thread.CurrentThread when processing historical data to count how many unique threads are there.

        One you start processing real time data, you are processing on an instrument thread. So once processing real time data, each instrument will be updating from one of the instrument threads. (You can have multiple instruments on one instrument thread, if you have more instruments than logical cores.)

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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by AttiM, 02-14-2024, 05:20 PM
        11 responses
        184 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by fernandobr, Today, 09:11 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by timmbbo, Today, 08:59 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by KennyK, 05-29-2017, 02:02 AM
        2 responses
        1,281 views
        0 likes
        Last Post marcus2300  
        Started by itrader46, Today, 09:04 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X