I need to do a casting to reference to a subclass of BarsType.
But I always get an exception and not know why.
The issue is easy to reproduce if you load this indicator on a chart of minutes.
Any help is welcome.
Best Regards.
protected override void OnStartUp() { try { // A "superclass variable" points to a "subclass object": BarsType a = this.Bars.BarsType; // The Print is ok, because this.Bars.BarsType is of the type "MinuteBarsType" Print( a.GetType().ToString() ); // ... "NinjaTrader.Data.MinuteBarsType" // The casting fails although the types are equals. And I dont know why. NinjaTrader.Data.MinuteBarsType b = (NinjaTrader.Data.MinuteBarsType)a; } catch( Exception e ) { Print( e.ToString() ); } }
Comment