An indicator is declared at class level within the strategy for example: private GomiLadderIntegratedYMRealtime myTickReplayIndicatorYM = null;
This variable is then set using the following code in the State == State.DataLoaded
foreach (var x in ChartControl.Indicators)
{
if (x.Name == "GomiLadderIntegratedYMRealtime")
{
myTickReplayIndicatorYM = (GomiLadderIntegratedYMRealtime)x;
myTickReplayIndicatorYM.IsSuspended = false;
}
}
This then allows access to the properties of the indicator as the strategy is running in real time.
This mechanism works however there is an intermittent error that occurs which seems to be fixed after refreshing the chart once or twice which indicates the compiler is having trouble matching the variable declared in the strategy to the object [indicator] of the same type :
[B]YMInfinity3EngineRealtimeCalculateAzureMLNet2: State == State.DataLoaded [A]NinjaTrader.NinjaScript.Indicators.GomiLadderInteg ratedYMRealtime cannot be cast to NinjaTrader.NinjaScript.Indicators.GomiLadderInteg ratedYMRealtime. Type A originates from 'NinjaTrader.Custom, Version=8.0.24.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadFrom' at location 'C:\Users\DESKTOP-B322BQ3\Documents\NinjaTrader 8\bin\Custom\NinjaTrader.Custom.dll'. Type B originates from 'f48d05ceef0445478bdd9f83fcbed491, Version=8.0.24.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadFrom' at location 'C:\Users\DESKTOP-B322BQ3\Documents\NinjaTrader 8\tmp\f48d05ceef0445478bdd9f83fcbed491.dll'. |
Comment