Sorry if this is a stupid question (!)
I'm building an indicator which draws a line following a move in price.
Within OnBarUpdate I check if the price move meets my conditions and then draw the line from my calculated start point.
Before I draw the line I check if there is any existing line from the same start point using the following code
for (int a3 = CurrentBar; a3 > (CurrentBar - SwingLowCandle_a); a3--) //remove previous lines drawn for the same impulse { if (DrawObjects[a3 + "line1"] != null) { RemoveDrawObject(a3 + "line1"); Print("Drawing Object " + a3 + "line1 removed."); } }
So I then tried just wrapping my original code in a foreach as below:
foreach (DrawingTool draw in DrawObjects.ToList()) { for (int a3 = CurrentBar; a3 > (CurrentBar - SwingLowCandle_a); a3--) //remove previous lines drawn for the same impulse { if (DrawObjects[a3 + "line1"] != null) { RemoveDrawObject(a3 + "line1"); Print("Drawing Object " + a3 + "line1 removed."); } } }
I just wanted to double check that my method is correct?
Many thanks
Tim
Comment