I want to find all the "ExtendedLine" lines on the chart and use this code:
int size = s.DrawObjects.Count; Print("size: "+size.ToString()); if (size > 0){ foreach (DrawingTool draw in s.DrawObjects.ToList()){ if (draw is DrawingTools.ExtendedLine){ Print ("Tag name: "+draw.Tag); DrawingTools.ExtendedLine temp = draw as DrawingTools.ExtendedLine; Print("startY: " + temp.StartAnchor.Price); Print("startX: " + temp.StartAnchor.Time); Print("endY: " + temp.EndAnchor.Price); Print("endX: " + temp.EndAnchor.Time); } } }
Next, I add another the same line - and the code already defines this line. As you can see, the size is already 3, but only the last line is defined as "DrawingTools.ExtendedLine":
Next, I go into the settings of one of the lines, add a new character to Tag, delete this new character (so that the Apply button becomes active). I click apply. Now the code sees and distinguishes all three lines:
Comment:
The strategy always sees these lines, but not always a successful check:
if (draw is DrawingTools.ExtendedLine)
Question:
What is it and why?
How can I achieve stable operation of this function without additional obscure actions?
Comment