Multi-Time Frame & Instruments

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Educational Resources >

Multi-Time Frame & Instruments

Previous page Return to chapter overview Next page

Show/Hide Hidden Text

Multi-Series Scripting Overview

NinjaScript supports multiple time frames and instruments in a single script. This is possible because you can add additional Bars objects to indicators or strategies, in addition to the primary Bars object to which they are applied. A Bars object represents all of the bars of data on a chart. For example, if you had a MSFT 1 minute chart with 200 bars on it, the 200 bars represent one Bars object. In addition to adding Bars objects for reference or for use with indicator methods, you can execute trades across all the different instruments in a script. There is extreme flexibility in the NinjaScript model that NinjaTrader uses for multiple-bars scripts, so it is very important that you understand how it all works before you incorporate additional Bars objects in a script. An important fact to understand is that NinjaScript is truly event driven; every Bars object in a script will call the OnBarUpdate() method. The significance of this will become evident throughout this page.

 

Note:  If using OnMarketData(), a subscription will be created on all bars series added in your indicator or strategy strategy (even if the instrument is the same).  The market data subscription behavior occurs both in real-time and during TickReplay historical

 

It is also important that you understand the following method and properties:

 

AddDataSeries()

BarsArray

BarsInProgress

CurrentBars

 

Note:  As we move through this section, the term "Primary Bars" will be used and for the purpose of clarification, this will always refer to the first Bars object loaded into a script. For example, if you apply a script on MSFT 1 minute chart, the primary Bars would be MSFT 1 minute data set.

 

This section is written in sequential fashion. Example code is re-used and built upon from sub section to sub section.

tog_minus        Working With Multi-Time Frame Objects

tog_minus        Adding Additional Bars Objects to NinjaScript

tog_minus        Creating Series<T> Objects

tog_minus        How Bars Data is Referenced

tog_minus        Using Bars Objects as Input to Indicator Methods

tog_minus        True Event Driven OnBarUpdate() Method

tog_minus        Accessing the Price Data in a Multi-Bars NinjaScript

tog_minus        Entering, Exiting and Retrieving Position Information