Definition
The Initialize() method is called once when starting a strategy. This method can be used to configure indicator and strategy properties.
For example:
• | Strategies - Call the Add() method to add indicators to charts and to add additional Bars objects to the strategy |
• | Although this method is called once on the start of an indicator or strategy, there are times that this method is also called (Opening an indicator dialog) when you may not expect it to. FOR ADVANCED PROGRAMMERS, DO NOT USE THIS METHOD TO RUN CUSTOM ROUTINES SUCH AS OPENING FORMS, MAKING EXTERNAL CALLS SUCH AS A LICENSE CHECK. PLEASE USE OnStartUp() FOR THOSE PURPOSES. |
Method Return Value
This method does not return a value.
Syntax
See example below. The NinjaScript indicator and strategy wizards automatically generate the method syntax for you.
Examples
protected override void Initialize()
{
Add(Instrument, PeriodType.Minute, 5);
}
|
|
|