I want to avoid using TL_Delete and Text_Delete commands because of the havoc they play on object IDs. Can't figure out why these objects only dwell for one tick. I have tried defining the variables both intrabarpersist and not--no difference.
Any thoughts appreciated.
PDQ
Code: Select all
{************************************************************************************************************************************************************
inputs and variable initialization section
************************************************************************************************************************************************************}
Inputs:
Font_Size (9),
Bold_Text (true);
variables:
YH (0),
Text_Plot_Date (0),
Text_Plot_Time (0),
Text_YH (-1),
Text_YH_str (""),
Line_YH (-1);
{************************************************************************************************************************************************************
get global variable values section
************************************************************************************************************************************************************}
YH = high + 4; { plot a line 4 points above current bar high}
{*************************************************************************************************************************************************************
plot section
*************************************************************************************************************************************************************}
Text_Plot_Date = JulianToDate(GetAppInfo(aiRightDispDateTime)); { gets the close of the rightmost bar on the chart }
Text_Plot_Time = DateTime2ELTime(GetAppInfo(aiRightDispDateTime)); { converts time to EL time }
Text_YH_str = "YH: " + numtostr(YH,1);
if LastBarOnChart then once begin { initialize trendlines and text }
Line_YH = TL_new(date, time, YH, Text_Plot_Date, Text_Plot_Time,YH);
TL_SetExtRight(Line_YH,true);
TL_setsize(Line_YH,0.5);
TL_setstyle(Line_YH,tool_dashed2);
TL_setcolor(Line_YH,blue);
Text_YH = Text_new(Text_Plot_Date,Text_Plot_Time,YH,Text_YH_str);
Text_SetColor(Text_YH,blue);
Text_SetStyle(Text_YH,1,1);
Text_SetAttribute(Text_YH,1,Bold_Text);
Text_SetSize(Text_YH,Font_Size);
end;
if barstatus = 2 then begin { moves trendlines and text on bar close }
TL_SetBegin(Line_YH,date,time,YH);
TL_SetEnd(Line_YH,Text_Plot_Date,Text_Plot_Time,YH);
Text_SetString(Text_YH, "YH: " + numtostr(YH, 1));
Text_SetLocation(Text_YH,Text_Plot_Date,Text_Plot_Time,YH);
end;
{*************************************************************************************************************************************************************
diagnostic print section
*************************************************************************************************************************************************************}
Print(
"Date= ", date,
" Time= ", time,
" YH= ", YH,
" LastBarOnChart= ", LastBarOnChart,
" barstatus= ", barstatus,
" Text_YH_str= ", Text_YH_str,
" Text_Plot_Date= ", Text_Plot_Date,
" Text_Plot_Time= ", Text_Plot_Time
);