Hi Martin,
The TL_ commands only work on trend lines. I guess the horizontal line is different. This is why they need to create a function for the user to allow the Shift key to force the actual trend lines to be horizontal or vertical or whatever. This feature would render the horizontal line almost obsolete because you could then use the TL_ commands on these true trend lines.
If your line is a true trend line and created by EL code then you can force it to be horizontal and this line can be detected by the code (again because it is a trend line).
This is the basic logic for those commands that I developed by studying the output result of those commands.
Code: Select all
TL_ID = 0;
While TL_ID > -2 {If -2 then all trend lines on the chart have been processed}
begin
if TL_ID = 0 then
begin
TL_ID = TL_GetFirst(7);
end
else
begin
TL_ID = TL_GetNext(TL_ID,7);
end;
if TL_ID > 0 then
begin
TLBeginDate = TL_GetBeginDate(TL_ID);
TLBeginTime = TL_GetBeginTime(TL_ID);
TLEndTime = TL_GetEndTime(TL_ID);
TLEndDate = TL_GetEndDate(TL_ID);
end; {if TL_ID > 0 then}
end; {While TL_ID > -2}
So all you do is get the price data from the line being inspected and if the start and the end prices are the same then it is horizontal. You can store it in GVs and create it elsewhere. However, what happens if you have more than one horizontal line? You need to store their IDs so that this process does not set up an infinite loop. Maybe you test for manual trend lines to help here. It you are deleting lines it could get tricky because MC will reuse the line number for the next ID.
By the way, the link below points to a base code which could be used to build a script which will force the manually created trend line to be horizontal. So how would this work you might be asking. First you need to study the code below until you understand it fully. Next you create the trend line and the script which is created from that base code is capturing the ID of all highlighted lines using MC_TL_GetActive. It will have the ID of the line you just put on the chart. So you immediately highlight the text from that base code and it will use the TL ID it has captured and force that line to be horizontal (have text for horizontal and vertical). So this may be your solution. I would have created that I guess but I do not use trend lines.
Base Logic for Interactive Text Script: Likely of use to all
viewtopic.php?f=5&t=7764
I gather there is a way to detect key strokes in a script now. I have not used it. You may be able to force trend lines to horizontal or vertical this way. I am thinking a script would detect the trend line highlighted using MC_TL_GetActive and also detect the shift key and force it horizontal.
John