Using the SampleMultiTimeFrame strategy that NinjaTrader has given us they declare their 6 SMA variables, sma50b0 to b3, sma5b0 to b3
Next in Data.Loaded they call the first 2 (sma50b0 and sma5b0) which establishes their period and then they add it to the chart.
Next in OnBarUpdate they call the other 4 variables via an if variable is null, assign this command. State.DataLoaded seems like it would be a better place to initialize these 4 variables but either way it works in this instance.
Copying this format I am setting up a linear regression channel. It's declared just below the public class ... : strategy;
private OrderFlowVWAP VWAP;
State.DataLoaded if (VWAP == null) { VWAP = OrderFlowVWAP(VWAPResolution.Standard, Bars.TradingHours, VWAPStandardDeviations.Two, 1,2,3); a bunch more code AddChartIndicator(VWAP);
Any idea why this might be the case and/or how this should be handled? From the example it seems like the correct way to do it.
Edit: is there an issue using the if( indicator == null) then assign values as NT may not be reading it as null since it was assigned?
Comment