When I did this Connect, I also noticed that the NinjaTrader bug still exists where either FirstBarIndexPainted and/or LastBarIndexPainted ends up with a value of -1 in the first call (after the Connect) to an indicator's custom GetMinMaxValues method or its custom Plot method.
This will in general cause an error for any indicators that use custom Plot/GetMinMaxValues methods that reference these values.
This is a long-standing bug for 7.0. (Sorry I thought I'd reported this before, but I must not have completed the posting.)
This also used to affect custom indicator use when connecting to Replay (I haven't used Replay in a while, so I'm not sure this is still an issue there, but I suspect it is, as I'd guess the problem is probably in Ninja's Connect code which gets called in either case.)
As a workaround I had been using code similar to the following in my indicators with custom Plot/GetMinMaxValues methods:
#if NT7 // For V7.0... if ((FirstBarIndexPainted < 0) || (LastBarIndexPainted < 0)) { string errMsg = String.Format( "{0} = {1} - GetMinMaxValues - Negative bar number error(s) - FirstBarIndexPainted={2} LastBarIndexPainted={3}", base.Name, DateTime.Now, FirstBarIndexPainted, LastBarIndexPainted ); Print( errMsg ); // Display an error message in the Output window. Log( errMsg, LogLevel.Warning ); // Also display the error message in the Control Center's Log tab. return; // Compensate for Replay slider bug in Ninja 7.0.1000.2 & earlier; error also seen on Connect after Disconnect done Monday morning 7.0.1000.7 (10-Oct-2011). } #else // For V6.5... int FirstBarIndexPainted = ChartControl.LastBarPainted - ChartControl.BarsPainted + 1; // First bar index painted wasn't defined in V6.5. int LastBarIndexPainted = ChartControl.LastBarPainted; // Last bar index painted wasn't defined in V6.5. #endif
Comment