Definition
This is method provides two functions:
1. Adds a Bars object to a strategy for developing a multi-time frame or multi-instrument strategy. When running a strategy, the NinjaTrader UI will prompt you to select the primary instrument and bar interval to run on. This primary Bars object will carry a BarsInProgress index of 0. In a multi-time frame and multi-instrument strategy, supplementary Bars objects are added via this method in the Initialize() method and given an incremented BarsInProgress index value. See additional information on running multi-bars strategies.
2. Adds an indicator to the strategy only for the purpose of displaying it on a chart.
Note: The Add() method should only be called within the strategy Initialize() method.
Syntax
Add(Indicator indicator)
The following syntax will add another Bars object to the strategy for the primary instrument of the strategy.
Add(PeriodType periodType, int period)
The following syntax allows you to add another Bars object for a different instrument to the strategy.
Add(string instrument, PeriodType periodType, int period)
NOTE: You can optionally add the exchange name as a suffix to the symbol name. This is only advised if the instrument has multiple possible exchanges that it can trade on and it is configured within the Instrument Manager. For example: Add("MSFT Arca", PeriodType.Minute, 5).
|
Parameters |
|
|
indicator |
An indicator object |
|
instrument |
An instrument name such as "MSFT" |
|
periodType |
The period type of the bar such as: PeriodType.Day PeriodType.Minute PeriodType.Tick PeriodType.Volume |
|
period |
The period interval such as "3" for 3 minute bars |
Examples
|
protected override void Initialize()
// Add a 100 tick Bars object for the ES 12-06 contract - BarsInProgress index = 2
|