NinjaScript > Educational Resources > Tips >

Multi-Threading Consideration for NinjaScript

Print this Topic Previous pageReturn to chapter overviewNext page

With the introduction of multi-threading in NinjaTrader when doing things like optimizations special considerations should be made when programming your NinjaScript indicators and strategies. Multi-threading basically allows NinjaTrader to take advantage of multi-core CPUs commonplace in modern computing to do multiple tasks at the same time. What this means for an optimization run is that multiple iterations can be tested by utilizing the various cores available to the computer.

 

Should you be using custom resources like text files, static members, etc. it is important to protect your resources from concurrent access. If NinjaTrader tried to use the resource at the same time you would run into errors similar to this one:

 

8/20/2010 12:14:29 PM|3|128|Error on calling 'OnBarUpdate' method for strategy 'SampleStrategy/1740b50bfe5d4bd896b0533725622400': The process cannot access the file 'c:\sample.txt' because it is being used by another process.