NinjaTrader Development Blog



The Accumulation/Distribution Line (ADL) is a volume-based indicator used in technical analysis to help traders determine the flow of money into or out of a security. It was developed by Marc Chaikin and aims to measure the cumulative flow of money, thereby helping to identify buying or selling pressure in a stock, which can signal potential reversals or confirm trends.

The Relative Strength Index (RSI) is a momentum oscillator used in technical analysis that measures the speed and change of price movements. RSI oscillates between zero and 100 and is typically used to identify overbought or oversold conditions.

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.

Quite often, if you do not serialize your Brush parameters in your NinjaTrader strategy or indicator you will be fine but only until you try saving your presets. When a preset is saved all parameters are actually serialized into a string on the backend and if you have not handled the Brush parameter properly in your code then you will get a problem, you won't be able to save parameters and NinjaTrader might also crash. Below is how to properly handle this situation:

Quite often we need to add a time selector to NinjaTrader indicator or strategy parameter list. The usual to do this would be like this:

The task was to get selected chart trader account pnl and print its values out on a chart trader. The numeric value at the bottom of this custom chart trader reads the live pnl and also updates when it changes. 

In order for the value to get updated you have to additionally inherit the strategy class from INotifyPropertyChanged interface. Once you do that you also have to implement it like this:

Many times we get a situation where we want to plot some lines on the chart. Sometimes these lines need to come on and off and when they would come off their value would be zeroed out or they might become irrelevant such as become n/a.

This topic has been breaking my head for over a few years now for quite a few reasons. Let's review a few of the main ones.

First of all we need to say that NinjaTrader architecture has two possible ways of executing inside the OnBarUpdate method which are either on each incoming tick or on each incoming bar close. Now, I will skip the on price change one which I don't use at all. 

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?

NinjaTrader offers and amazing opportunity for all of us! It has a wide community and you are free to make products and grow together with the platform.

I decided to make a quick guide on how this works in this post since I do get this asked quite often and honestly it was a bit confusing right from the start on how this actually works.

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! 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!