TL_Delete (Reserved Word)

image\trumpet2.gif Disclaimer

This reserved word deletes the specified trendline from the price chart.

Value1 = TL_Delete(Tl_ID)

Tl_ID is a numeric expression representing the ID number of the trendline to delete.

Value1 is any numeric variable or array.

  When the trendline is successfully deleted, it returns 0. It is important to remember that if an invalid ID number is used, the reserved word will return a value of -2 and no additional operations will be performed on any trendlines by the trading strategy, analysis technique, or function that generated the error. For a list of error codes, see EasyLanguage Drawing Object Error Codes.

Example

The following deletes the trendline with the identification number 3:

TL_Delete(3);

To obtain the error code (or 0 when no error) returned by the reserved word, you can assign the reserved word to a numeric variable, as follows:

Value1 = TL_Delete(3) ;

Additional Example

The following statements draw a trendline at the low of a key reversal and extend it to the right, and in addition, delete the old trendline from the chart when a new key reversal is found:

Variables: OldKeyID(-1), ID(-1);

If Low < Low[1] AND Close > High[1] Then Begin

OldKeyID = ID;
ID = TL_New(Date[1], Time[1], Low, Date, Time, Low);
Value1 = TL_SetExtRight(ID, True);
If OldKeyID <> -1 Then

Value1 = TL_Delete(OldKeyID);

End;

In the above example, first we declare two variables, one to hold the ID number of the old trendline, and one to hold the ID number for the new trendline. When we find a new key reversal, we store the existing trendline’s ID number in OldKeyID, and create a new trendline at the low of the key reversal bar and extend it to the right. Then, we delete the old trendline. Before deleting the old trendline, we first check to make sure the ID number in OldKeyID is not -1, which it will be until the second trendline is drawn. This way, we don’t reference an invalid ID number.

See Also

TL_GetActive

TL_GetAlert

TL_GetBeginTime

TL_GetBeginVal

TL_GetColor

TL_GetEndDate

TL_GetEndTime

TL_GetEndVal

TL_GetFirst

TL_GetNext

TL_GetValue

TL_New

TL_SetBegin

TL_SetEnd

Trendline (class)