Either the NT8 help documentation is inconsistent with itself regarding where a Series<T> should be instantiated, or perhaps the answer is "it depends".
On the main NT8 "OnStateChange()" documentation page (https://ninjatrader.com/support/help...tatechange.htm), the grid row for "State.Historical" has the following bullet point under the column "this is where you should":
"Initialize any class level variables (including custom Series<T> objects)"
However, on the "NinjaScript Best Practices" page ( https://ninjatrader.com/support/help..._practices.htm ), under the "State management practices" header, it recommends that a Series<T> be instantiated in the "else if (State == State.DataLoaded)" if/else branch:
else if (State == State.DataLoaded) { // Since these values do are dependent on bars, they should only reset during State.DataLoaded mySMAIndicator = SMA(14); mySeries = new Series<double>(this); }
else if (State == State.DataLoaded)
{
MyDataSeries = new Series<double>(this);
}
When should a Series<T> object be instantiated in the "else if (State == State.Historical)" section?
Thank you very much in advance,
EquityTrader
Comment