Drawing Object Question

Questions about MultiCharts and user contributed studies.
PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Drawing Object Question

Postby PD Quig » 27 Jan 2014

I have a simple test routine that draws a TL and text object and moves them at the close of each bar. It works fine in playback mode, but the TL and text disappear one tick after being drawn in real-time mode.

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
);
Attachments
drawing object testing.wsp
(124.2 KiB) Downloaded 371 times
Drawing_object_testing.pla
(9.13 KiB) Downloaded 373 times

Dru
Posts: 107
Joined: 28 Aug 2007
Has thanked: 4 times
Been thanked: 171 times

Re: Drawing Object Question

Postby Dru » 28 Jan 2014

...
[RecoverDrawings = false]
variables:
YH (0),
Text_Plot_Date (0),
Text_Plot_Time (0),
intrabarpersist Text_YH (-1),
Text_YH_str (""),
intrabarpersist Line_YH (-1);
...

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Drawing Object Question

Postby PD Quig » 28 Jan 2014

Dang, Dru. Thanks. Shows what a few sleepless nights will do for your thinking process...(very similar issue last week). Feel like Homer Simpson.


Return to “MultiCharts”