Solution to Deleting text with EL problem.

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Solution to Deleting text with EL problem.

Postby bowlesj3 » 07 Sep 2007

Hi,

I thought I would pass this trick on just in case another user has this problem which I finally found the solution to.

I have a lot of short text codes placed out front of price on my 1 minute bar chart to help with trade planning and triggering. Earlier on I was going back and using the text ID code to delete text I did not need at the moment. This was causing a problem in that MC (or EL maybe) was deleting the wrong text since somehow the text ID codes were getting duplicated (especially if the text is applied via different systems). So what I found solved the problem was to never delete it but rather just blank it out and to have only one system assigning the text but calling different functions for different types of text. The code to solve this is below (it is one of the functions). I store the Text ID and send it back to the system to be held the same all day.

Now here is the interesting part. While trying to solve a problem and using the print statement I learned that the Text ID gets changed even though I try to grab it and hold it all day in the system. The code below still seems to works but I don't quite understand why MC reassings it somehow even though I store it in a variable in the calling system.

Note that in the function below, if the price location is zero this means I don't want to see the text so I blank it and place it hidden at the closing price. Again if I try and delete it, MC will end up deleting the wrong text at times and that to say the least can be very annoying and is a hard bug to figure out.

Unfortunately I just did a preview of the message and the proper indentation for code readability does not work.


{A_Place1ProjectionText ==================================================}

{This function places one projection text on the 1 minute bar chart.}
inputs:
TextColor(NumericSimple), {Color you want for this Projection Text}
Wave(StringSimple), {Wave and Projection Type}
TxtID(NumericSimple), {ID for this text}
TimeLoc(NumericSimple), {Minutes to place projection text forward of last band text price}
ProjPrice(NumericSimple) {Price position to place the projection text}
;

variables:
TimeLoc2(0),
ReturnCode(0),
TextID(0);

TextID = TxtID;
if ProjPrice > 0 then
begin
if TextID = 0 then
begin
TextID = text_new(date, TimeLoc, ProjPrice, Wave);
ReturnCode = Text_SetColor(TextID, TextColor);
end
else
begin
ReturnCode = Text_SetLocation(TextID, date, TimeLoc, ProjPrice);
returncode = text_setstring(TextID,Wave);
end;
end
else
begin
if TextID = 0 then
begin
TextID = text_new(date, TimeLoc2, Close, "");
ReturnCode = Text_SetColor(TextID, TextColor);
end
else
begin
ReturnCode = Text_SetLocation(TextID, date, TimeLoc2, Close);
returncode = text_setstring(TextID,"");
end;
end;

A_Place1ProjectionText2 = TextID;

Return to “User Contributed Studies and Indicator Library”