NinjaTrader Development Blog



The push to write this article in particular came due to numerous amounts of similar questions that come in from NinjaCoding clients and visitors who want to buy strategies published on the website. In his article I will try to answer some of the most famous ones that get asked almost every time.

It has been a long time question and I was thinking on dedicating a proper page to this topic and procrastinating this discussion for years until I remembered that I have a blog!!!))

Let's imagine you are someone who knows nothing about coding and strategy development. An absolute blank or as we say "tabula rasa". Where should one start?

This is a painful spot for NinjaTrader and I have already written quite a few blog posts on this but just recently I came across a quick walking stick that I would like to share.

Basically to outline a problem imagine two bars. You get filled on one bar lets say at 15:00, next bar is 15:05 and previous bar is 14:55. So you get filled whilst the 14:55 - 15:00 bar is forming, so a bar with 15:00 close time.

The first question that I always ask myself is "do I have a friend who I can call and he will tell me how is it right to trade the market and whether it is going to be an up or down day tomorrow" and the answer is always definitely no and probably no one has one like that.

The other half of this topic should say "... and not get 1 million of errors printed". NinjaTrader manual is actually very helpful and it says you can, all you have to do is use this setting:

Hello guys! Yes, this blog will not only be about the boring side of it all with all this code and code and code and code and neverending bugs))). Yes!!! I will share my experience with some cool entries, exits, and trading techniques so stay tuned and, common, subscribe! This is the worst marketer calling for it so go for it right now and press subscribe!


Hello guys! More code snippets here! So, NinjaTrader offers a default function for you to set your stop size which is:

SetStopLoss(CalculationMode.Currency, 200);

Easy done! Just put this into the OnState.Configure and you are pretty much done and for many cases, this can be enough, however, for most of the cases that require a careful and more controlled approach to stop handling this is not enough at all.

Hello guys! We are back on track with some hot stuff!) So simple example straight into the business. Imagine you need to optimize your strategy and you want to use profit factor as the optimization fitness parameter but some results return very good profit factor but unfortunately too few trades to take these results seriously statistically and you want to exclude them completely.


Did you know that you can use WPF to add any type of functionality to your NinjaTrader strategy or indicator classes? Well, yes you can. In this article, we will be adding a WPF window form to a strategy and passing values to the form and receiving values back.


So the whole set up consists of a few elements.

  1. AddOn code

  2. XAML code for the form

  3. Strategy code



In this article, I will give out a secret that will save you some headache time. I bet many of you might have come across this issue already and if you have not then you will 100% meet it if you ever design a multi-timeframe trading system for NinjaTrader where one of the symbols is slower than the other.

You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.”.


As we all know, NinjaTrader can be executed in two main modes. Either OnEachTick or OnBarClose. There is also OnPriceChange but we are not going to talk about it in this article.

OnEachTick and OnBarClose control how the OnBarUpdate is called during execution. When execution on EachTick whenever a new tick of data arrives into NinjaTrader the OnBarUpdate is called.