As a small piece of a routine that draws a varying number of trend lines at the close of each bar, I want to delete all existing trend lines on the close of a bar. No matter what I try, I can only get one TL to delete. Here's what I thought would work:
Code: Select all
variables:
ID (0);
if LastBarOnChart and barstatus = 2 then begin
ID = TL_GetFirst(3); { tl of any origin }
while ID > 0 begin
TL_Delete(ID);
ID = TL_GetNext(ID, 3);
end;
end;
When I draw three manual trend lines on the chart and step through in playback mode, only a single line is deleted per bar. Print statements inserted into this snippet reveal that after the TL_GetNext statement the value of ID = -2 after each trend line is deleted. Why isn't it getting the 2nd or 3rd trendline ID?
I must be missing something obvious.
Thanks in advance.