NinjaTrader Development Blog

Suggest Blog Topic

Hello guys! Before I start a long story for this post I really want to thank the support team from NinjaTrader who have helped a lot to clarify the further discussed topic and more than that have actually clarified and helped with far more questions so a big thank you for all of them if any are reading this post!

Hello guys! I have finally managed to put myself together and present you with a really interesting indicator that I have been planning to develop for ages!

We all know of divergence concepts where we can analyse different market indicators against price or against each other to figure out whether the market still has remaining momentum to move in the desired direction or whether it is possibly running out of power!

This is a very popular topic. We can add buttons to pretty much anything in NinjaTrader using the same principles. Buttons can be added from AddOn, Indicator or Strategy class doesn’t really matter. The approach is almost the same for all of them. In this article, I will go through the main principles that you need to understand when adding buttons.

Let’s imagine a scenario where we need to look back at High and Low of a 9:30 bar close during the day. How would we do this?

First of all, inside the OnBarUpdate method, you would need to set look update like this:

var today = Time[0];

var dateTime = new DateTime(today.Year, today.Month, today.Day, 9, 30, 0);


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.

NinjaTrader uses the managed order handling mode by default and you can run into a few scenarios when you wrote all of your code and suddenly your orders start getting ignored although it seems that everything you wrote is very logical.


DI+ DI-  is a great play around indicator that I built for NinjaTrader. It is based on a few very simple yet effective concepts Welles Wilder came up with ages ago. You can build quite a few strategies using these indicators and apply them as filters and tools in quite a few trading scenarios. 



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.


Hello everyone! If you have not read the first part of this article yet it might be a good idea. Nevertheless, this time we will be looking at the case of why you can get this error on live market or during market replay in NInjaTrader.

“Sell stop or sell stop limit orders can’t be placed above the market. Strategy submitted an order that generated the following error - order rejected. Strategy has sent cancel requests, attempted to close the position and terminated itself.”

I bet you have received this frustrating message a few times whilst using NinjaTrader!

“Sell stop or sell stop limit orders can’t be placed above the market. Strategy submitted an order that generated the following error - order rejected. Strategy has sent cancel requests, attempted to close the position and terminated itself.” Carry on and read more to find out more!