NinjaTrader Strategy Backtesting and Optimization

NinjaTrader’s support for strategies is definitely superior to that of StrategyDesk. NinjaTrader allows strategies to control the number of shares bought and sold, so it can be setup to roll profits into the next trade for backtesting (you could do taxes as well, but I haven’t bothered with that yet). The optimizer is pretty straightforward. A strategy can define a number of parameters and then the optimizer can be told to run through a range of values for each parameter by a specific increment and the optimizer runs the strategy through all combinations of input values. The optimizer also lets you select from canned criteria on what to maximize, but I found their options a little odd. While this functions well enough its quite slow, and not just because its test space is exponential. NinjaTrader is written in C# as are its canned indicators and the problem with that is that the .Net runtime is pretty piss poor at floating point performance (gamed benchmarks from people trying to ‘prove’ Java or .Net faster then C/C++ not withstanding). On top of that it isn’t multi-threaded, so it doesn’t take advantage of a multi-core box.

I’m currently trying to decide if I should just keep letting it plug along, or if I should write up something in C++ using opentick as the datafeed, so I can get results coming out more quickly.

This entry was posted in Coding and tagged , , . Bookmark the permalink.

5 Responses to NinjaTrader Strategy Backtesting and Optimization

  1. Zach says:

    The calculations for the indicators aren’t written in C#, they’re a part of a C library called TA-Lib. The reason the optimizer is so slow is because it’s iterative. But there are solutions out there to fix that. Currently I’m using a Genetic Optimizer.

  2. jed rynkar says:

    Looking hard for genetic optimizer for stock trading strategies because I agree that Ninja’s is too slow. Any solutions out there that would be compatible with Ninja, TD ameritrade or E-signal? Metastock is another option but Tradestation is not. Thanks

  3. Glen says:

    The Script files made in Strategy Desk
    such as Bar[Close,1,1] ect can they be converted with a converter to the other codes like C++ or C sharp
    I dont know C sharp or C++ very well.
    As far a Strategy Desk is there anybody else but TD Ameritrade that uses it. TD hurt my Fathers account to the point of closeing it.
    Thanks Glen

  4. Andrew says:

    So far it works quit good to me, I bought the future market data from and did both optimizer and market replay test, it run good on my new Intel i7 64bits windows 7 with 16gb memory.
    What machine do you use to run? Josh.

    • The machine in question was built five years ago, so it’s specs are not very impressive. Keep in mind the post was from 3 years ago. Not only is your hardware better, but both NinjaTrader and Microsoft have had years to improve their performance.

Have something to say?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s