automated-trading.ch

Developing an OrderFlow Value Area Indicator on Ninjatrader 8

Published 1 year ago
Summary

In this article i'm going to guide you through developing a reusable class that calculates value areas on the Ninjatrader 8 platform. This reusable class can be used either inside an indicator or a strategy.

This article is an in-depth technical tutorial on how to develop value area classes and indicators using the C# programming language. It is mainly destined for software developers

The full source code of the developed class, full functional Indicator and an example Ninjatrader strategy are available to download.

Index
Prequisites

This Value Area class requires having the Lifetime License of the Ninjatrader 8 platform In order to access Volumetric OrderFlow Data

In order to obtain the same visual result as described in this article you have to download and install the Ninjatrader preset available in the download panel below. This preset modifies the default drawing settings of the volumetric bars

Download Full Source Code of ATFootprint.xml
  • Click on the Download button to download the file
  • This software is Licensed under the MIT License
  • This file was downloaded 37 times. Last download was 18 hours ago
15.9 Kb

You should copy the downloaded file into your Ninjatrader Templates folder located in
C:\Users\{Your Username}\Documents\NinjaTrader 8\templates\Chart

Once you get familiar with provided source code you can freely modify the render method of this indicator and adapt it to any other preset you wish

Introduction

Value areas are a well known orderflow trading tool that are based on volume statistics

In this article I'm not going to reinvent the wheel and explain the theory behind value areas. You can find in depth info about them on the internet.

Nevertheless in this article i'm going to write an in-depth technical tutorial on how to develop such functionality from scratch on the Ninjatrader platform

If you are not just looking for an indicator to install on the Ninjatrader platform but instead seeking to learn how to develop one from scratch then you've reached your destination.

Let me start by showing you the wanted result. Here what we are aiming for

Value-Area-Indicator-in-Ninjatrader-8
Click to enlarge

As you can see, we will draw a value area for each bar. Each value area has 3 main consitituents which are

  • POC: Point of control which is the price level tha contains the maximum volume that have been traded on the bar.
  • VaH : Value area High : The highest price level of the value area
  • VaL : Value area Low : The lowest price level of the value area
Specifications & Requirements

The first thing that we will do is define our requirements for the Value Area class that we are going to develop.

The first requirement will be that the ValueArea class should be usable seamlessly inside an Indicator and a Strategy To be able to achieve this requirement we will design our class to be a separate class from the Strategy or Indicator Ninjatrader classes.

It will be a self-contained C# class that can be instantiated inside a Strategy or an Indicator in the same manner.

The second requirement will be that the ValueArea class should use the NinjaTrader DirectX drawing engine since it's the fastest and most optimized way to draw on the chart. To achieve this we will implement and override the OnRender method in our new class

The third requirement is that our new ValueArea class should function seamlessly in both Real-time and Historical modes of the Ninjatrader platform

To be able to achieve this goal we will design our class to have a lifecycle that functions in both modes.

The difference between the two modes is that in Historical mode, the Ninjatrader platform triggers the OnBarUpdate method of either Strategy or Indicator only once for each price bar.

Whereas for the Realtime mode, the Ninjatrader platform triggers the OnBarUpdate for every tick of the price bar.

So how are we handling this?

The answer is we need to detect when a new bar is formed. every time a new bar is formed we will create a new instance of our ValueArea class that will be attached to the new price bar. Until now this should work for both Realtime and historical modes.

In the case of a historical mode, we will be able to generate the ValueArea entirely in one shot and we move on to the next bar with the next call to OnBarUpdate.

In the case of Realtime mode, the first call to OnBarUpdate will allow the creation of the new instance of ValueArea class for the current price bar and then the subsequent calls to OnBarUpdate will allow the calculation and update of the ValueArea along with the update of the current price bar.

The ValueArea class

From these requirements, we can already decide that our ValueArea class will have a method that we will call OnTickUpdate(...) that we are going to call with each call to OnBarUpdate() from the Strategy or Indicator

So here is the first draft of the structure of our ValueArea class:

Premium Content
This Article Is Not Free. You Can Access It For Only
$99 PURCHASE NOW
  • Buy Once Access Anytime
  • Full Source Code Included
  • Premium Support
  • Free Updates
Already Purchased This Article ? Login To Access It