When the trendline was broken, I had a function that deleted drawn objects if they contained PTL_or VTL_.
The last time I used it successfully was 2 years ago and now when I use it, the Rays aren't being deleted. I took a look in visual studio and saw that even though there are 17 drawn objects by bar#77, DrawObjects.Count = 0.
Below is the code that used to work as well as 2 screenshots for reference. Is there a different way to delete DrawObjects?
Thanks!
public void DeleteAllFromChartByTagContains(string text)
{
if (CurrentBar == 77)
{
Print("Stopping at: " + CurrentBar);
}
List<DrawingTool> itemsToRemove = new List<DrawingTool>();
foreach (DrawingTool dt in DrawObjects.ToList())
{
if (dt.Tag.Contains(text))
{
itemsToRemove.Add(dt);
}
}
foreach (DrawingTool dt in itemsToRemove)
{
string toRemove = "";
if (dt.Tag.Contains(text))
{
toRemove = dt.Tag;
RemoveDrawObject(toRemove);
}
}
}

Comment