I am using Draw.Text from the OnOrderUpdate procedure in a strategy, but when I do I get errors in the log like:
Error in 'OnOpenOrder': 'Object reference not set to an instance of an object.' |
Error in 'OnOrderStatus': 'Object reference not set to an instance of an object.' |
// class variables: NinjaTrader.NinjaScript.NinjaScriptBase ThisChartWindow;
protected override void OnBarUpdate() { if (ThisChartWindow == null) if (State == State.Realtime) ThisChartWindow = this; }
if (ThisChartWindow != null) { Draw.Text(ThisChartWindow, cp + "-Target", ProfitPotential.ToString("#,##0.00"), 5, TargetPrice, Brushes.White); Draw.Text(ThisChartWindow, cp + "-StopLoss", LossPotential.ToString("#,##0.00"), 5, StopLossPrice, Brushes.White); }
Thanks.
Comment