Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multithreaded indicator programming

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

    Multithreaded indicator programming

    Hello,
    Does it make sense to do multithreaded programming in an NT7 indicator (for example in the hope of playing sounds without the charts lagging or to make use of multiple cores for intensive calculations), or will the code be executed anyway in a single thread/core?
    Thanks

    #2
    supernatural, everything would be run in the same thread.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Please put it on a feature list for a future release as this is a must have in the age of multicore processors (and long existing multithreaded OSs).

      Comment


        #4
        Thank you for the suggestion. I have forwarded it along.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Regarding play sounds - are you sure they are not asynchronous. It's very easy to check.

          More generally - I would bet that implementing multithreading indicators would require much more intimate knowledge of NT internals we have.

          Comment


            #6
            If I play a sound for each bar in my indicator (at the end of the OnBarUpdate method), I hear the sound first then about half a second later, I see the corresponding bar appearing on the chart (the one that triggered that sound), so apparently they're not asynchronous. Playing the sound in a separate thread doesn't really improve anything.

            By multithreaded indicator, I just mean I would spawn a few threads when the indicator is created (for example in the OnStartUp method) and then feed them custom calculations to be executed in parallel on a multiple core machine. I don't really need to know NT internals for that, just that it let me create threads that actually execute asynchronously.

            Comment


              #7
              Originally posted by supernatural View Post
              If I play a sound for each bar in my indicator (at the end of the OnBarUpdate method), I hear the sound first then about half a second later, I see the corresponding bar appearing on the chart (the one that triggered that sound), so apparently they're not asynchronous. Playing the sound in a separate thread doesn't really improve anything.

              By multithreaded indicator, I just mean I would spawn a few threads when the indicator is created (for example in the OnStartUp method) and then feed them custom calculations to be executed in parallel on a multiple core machine. I don't really need to know NT internals for that, just that it let me create threads that actually execute asynchronously.
              There is another thread where NT support confirmed that playsound happens aychnc.

              The system Pivots indicator has an example of asynchronous threads invoked from within NT. Do not expect any support though.

              Code:
              			if (!isDailyDataLoaded)
              			{
              				if (priorDayHLC == HLCCalculationMode.DailyBars && Bars.BarsType.IsIntraday) 
              				{
              					Enabled = false;
              					System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(GetBarsNow));
              					return;
              				}
              
              				existsHistDailyData = false;
              				isDailyDataLoaded	= true;
              			}

              Comment


                #8
                That's interesting! Did anyone succeed in running multiple threads concurrently (across multiple cores) this way?

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                581 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                338 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                554 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                552 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X