List<double> _Closes = new List<double>(); _BarsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) => { if (errorCode != ErrorCode.NoError) { // Handle any errors in requesting bars here NinjaTrader.Code.Output.Process(string.Format("Error on requesting bars: {0}, {1}", errorCode, errorMessage), PrintTo.OutputTab1); return; } for (int i = 0; i < bars.Bars.Count; i++) { // Output the bars _Closes.Add(bars.Bars.GetClose(i)); } [COLOR="Red"] [B]// This return the correct count[/B][/COLOR] NinjaTrader.Code.Output.Process(this.Time[0].ToShortDateString() + " =>Count Within: " + [COLOR="red"]_Closes.Count[/COLOR] ,PrintTo.OutputTab1); // If requesting real-time bars, but there are currently no connections lock (Connection.Connections) if (Connection.Connections.FirstOrDefault() == null) NinjaTrader.Code.Output.Process("Real-Time Bars: Not connected.", PrintTo.OutputTab1); })); [COLOR="red"][B]//However this is always null[/B][/COLOR] NinjaTrader.Code.Output.Process(this.Time[0].ToShortDateString() + " =>Count Without: " +[COLOR="Red"] _Closes.Count[/COLOR] ,PrintTo.OutputTab1);
Is there to wait for for BarsRequest.Request to complete before executing any other code?
Comment