I am trying to draw some lines that could later on be removed in certain conditions, but when I try to declare the line at class level, I am getting two errors:
- Line is an ambiguous reference between NinjaTraderGUILine and NinjaTraderScriptDrawingToolsLine
- Cannot implicitly convert type NinjaTraderScriptDrawingToolsLine to NinjaTraderGuiLine
My code:
public class DivergenceIndicator : Indicator
{
private NinjaTrader.NinjaScript.DrawingTools.Line negDiv1;
...
protected override void OnBarUpdate()
{
Line negDiv1 = Draw.Line(this...)
NinjaTrader.NinjaScript.DrawingTools.Line negDiv1 = Draw.Line(this...)
protected override void OnBarUpdate()
{
// saving "myDot" creates an additional reference in memory
Dot myDot = Draw.Dot(this, "myDot" + CurrentBar, false, Time[0], Close[0], Brushes.Blue);
if (conditionToRemove)
{
// remove draw object will remove the object from the chart
RemoveDrawObject("myDot");
// but your local object "myDot" is still stored in memory.
// Explicitly setting to null will ensure object is marked for garbage collection
myDot = null;
}
}

Comment