Why doesn't text appear on chart ?

Questions about MultiCharts and user contributed studies.
johnromeronc
Posts: 53
Joined: 18 Feb 2011
Has thanked: 11 times
Been thanked: 13 times

Why doesn't text appear on chart ?

Postby johnromeronc » 02 Jul 2012

Hi all, As always - any and all - help and guidance is appreciated. I am trying to put text on a chart. The debug prints to the output window seems to point to it working -- Kinda. Noting appears on the chart and when I bring up the format drawing window, there is no text object there.
As you can see in the lines below from the output window, it "Kinda" appears to work. There are no errors returned, and a new handle-ID is created / returned. The next statements to set color and size work with no errors, they return 0 (zero). But there is nothing on the chart. A L S O - when I press the Ctrl-mouse key the 2nd time, it creates the same handle #, which tells me something did NOT work. In the log the price, date and time are different, a they should be as I moved the mouse before making the 2nd attempt to create text.

" O u t p u t L o g "
mouse click date time --> 41089.13
JOR_0 a simple numeric var--> 41089.13
Left Ctrl -> Date portion of MouseDtTm = 6/29/2012
Left Ctrl ->Time Portion of MouseDtTm = 3:00:41 AM
price --> 1348.45
handle returned from Text_New_s --> 7.00
return set color --> 0.00
return set size --> 0.00
mouse click date time --> 41089.24
JOR_0 a simple numeric var--> 41089.24
Left Ctrl -> Date portion of MouseDtTm = 6/29/2012
Left Ctrl ->Time Portion of MouseDtTm = 5:50:19 AM
price --> 1332.53
handle returned from Text_New_s --> 7.00
return set color --> 0.00
return set size --> 0.00

========== end of output log

Code: Select all

switch (getappinfo(aicalcreason)) begin
case CalcReason_MouseLClick :
if MouseClickCtrlPressed then begin
JOR_0 = MouseClickDateTime;
print("mouse click date time --> ",MouseClickDateTime);
print("JOR_0 a simple numeric var--> ",JOR_0);
print("Left Ctrl -> Date portion of MouseDtTm = ", DateToString(IntPortion(JOR_0)));
print("Left Ctrl ->Time Portion of MouseDtTm = ", TimeToString(FracPortion(JOR_0)));
print("price --> ", MouseClickPrice);
JOR_Txt_Hndl = text_new_s( JOR_0,JOR_0,MouseClickPrice,"sample text");
print("handle returned from Text_New_s --> ", JOR_Txt_Hndl);
JOR_0 = text_setcolor(JOR_Txt_Hndl, yellow);
print("return set color --> ", JOR_0);
JOR_0 = text_setsize(JOR_Txt_Hndl, 16);
print("return set size --> ",JOR_0);
// JOR_1 = text_new_s( Intportion(JOR_0),FracPortion(JOR_0),MouseClickPrice,JOR_Text);
// if JOR_Text = "a3" then JOR_Text = "b3";
// if JOR_Text = "b3" then JOR_Text = "c3";
end { if MouseClickCtrlPressed & CalcReason_MouseLClick }

again thanks in advance for suggestions or catching an error.

John Romero

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Why doesn't text appear on chart ?

Postby TJ » 02 Jul 2012

Hi all, As always - any and all - help and guidance is appreciated. I am trying to put text on a chart. The debug prints to the output window seems to point to it working -- Kinda. Noting appears on the chart and when I bring up the format drawing window, there is no text object there.
As you can see in the lines below from the output window, it "Kinda" appears to work. There are no errors returned, and a new handle-ID is created / returned. The next statements to set color and size work with no errors, they return 0 (zero). But there is nothing on the chart. A L S O - when I press the Ctrl-mouse key the 2nd time, it creates the same handle #, which tells me something did NOT work. In the log the price, date and time are different, a they should be as I moved the mouse before making the 2nd attempt to create text.

" O u t p u t L o g "
mouse click date time --> 41089.13
JOR_0 a simple numeric var--> 41089.13
Left Ctrl -> Date portion of MouseDtTm = 6/29/2012
Left Ctrl ->Time Portion of MouseDtTm = 3:00:41 AM
price --> 1348.45
handle returned from Text_New_s --> 7.00
return set color --> 0.00
return set size --> 0.00
mouse click date time --> 41089.24
JOR_0 a simple numeric var--> 41089.24
Left Ctrl -> Date portion of MouseDtTm = 6/29/2012
Left Ctrl ->Time Portion of MouseDtTm = 5:50:19 AM
price --> 1332.53
handle returned from Text_New_s --> 7.00
return set color --> 0.00
return set size --> 0.00

========== end of output log

Code: Select all

switch (getappinfo(aicalcreason)) begin
case CalcReason_MouseLClick :
if MouseClickCtrlPressed then begin
JOR_0 = MouseClickDateTime;
print("mouse click date time --> ",MouseClickDateTime);
print("JOR_0 a simple numeric var--> ",JOR_0);
print("Left Ctrl -> Date portion of MouseDtTm = ", DateToString(IntPortion(JOR_0)));
print("Left Ctrl ->Time Portion of MouseDtTm = ", TimeToString(FracPortion(JOR_0)));
print("price --> ", MouseClickPrice);
JOR_Txt_Hndl = text_new_s( JOR_0,JOR_0,MouseClickPrice,"sample text");
print("handle returned from Text_New_s --> ", JOR_Txt_Hndl);
JOR_0 = text_setcolor(JOR_Txt_Hndl, yellow);
print("return set color --> ", JOR_0);
JOR_0 = text_setsize(JOR_Txt_Hndl, 16);
print("return set size --> ",JOR_0);
// JOR_1 = text_new_s( Intportion(JOR_0),FracPortion(JOR_0),MouseClickPrice,JOR_Text);
// if JOR_Text = "a3" then JOR_Text = "b3";
// if JOR_Text = "b3" then JOR_Text = "c3";
end { if MouseClickCtrlPressed & CalcReason_MouseLClick }

again thanks in advance for suggestions or catching an error.

John Romero
You will need the values of the DATE and TIME_s.

Code: Select all

JOR_Txt_Hndl = text_new_s( JOR_0, JOR_0, MouseClickPrice,"sample text");

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Why doesn't text appear on chart ?

Postby JoshM » 02 Jul 2012

You will need the values of the DATE and TIME_s.

Code: Select all

JOR_Txt_Hndl = text_new_s( JOR_0, JOR_0, MouseClickPrice,"sample text");
Yes. Try replacing..

Code: Select all

JOR_Txt_Hndl = text_new_s( JOR_0, JOR_0, MouseClickPrice,"sample text");
with..

Code: Select all

Variables:
timeTextObj(0), dateTextObj(0);

timeTextObj = DateTime2ELTime_s(JOR_0);
dateTextObj = JulianToDate(JOR_0);
JOR_Txt_Hndl = text_new_s(dateTextObj, timeTextObj, MouseClickPrice,"sample text");
..to convert the DateTime format of MouseClickDateTime to PowerLanguage time format (HHmmss) and PowerLanguage date format (YYYmmdd).

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Why doesn't text appear on chart ?

Postby TJ » 02 Jul 2012

why don't you do a PRINT on dateTextObj, timeTextObj, to see if you have the variables correct?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Why doesn't text appear on chart ?

Postby JoshM » 02 Jul 2012

why don't you do a PRINT on dateTextObj, timeTextObj, to see if you have to variables correct?
Why should I? :) John goal was to create a text object on the chart, not print this to the output log. I can see from John's code example that he knows how to debug with Print(), so I trust that if he wants to check these variables, he can type Print() himself.

But if you question my code example and don't want to test it yourself, here you go:

Code: Select all

Variables:
timeThisMoment(ComputerDateTime);

if (LastBarOnChart_s = True) then
Print("Time: ", DateTime2ELTime_s(timeThisMoment), " date: ", JulianToDate(timeThisMoment));
Which gives:

Code: Select all

Time: 181104.00 date: 1120702.00

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Why doesn't text appear on chart ?

Postby TJ » 02 Jul 2012

why don't you do a PRINT on dateTextObj, timeTextObj, to see if you have to variables correct?
Why should I? :) ...
that's not meant for you.

johnromeronc
Posts: 53
Joined: 18 Feb 2011
Has thanked: 11 times
Been thanked: 13 times

Re: Why doesn't text appear on chart ? Not all the way righ

Postby johnromeronc » 02 Jul 2012

TJ and Josh - thanks for your time to reply and put some thought into it. I can now get text to appear on the chart, but it does not stay there under some conditions. Should I submit this as a bug?

Observations
- Debug still shows the same handle # being created again - every time I press Ctrl Mouse Left Click to create using Text_New_S within that Switch / Case block of code.
- Is there a "stay where I put ya" API / command (hehe)
- in follow on statements I can change color and text size
- other variables I update in the section of code for Mouse Events (Switch - Case) statements revert back to their prior values also.
- Any mouse click on the chart, Left, Right, or mouse key combo, causes the text object to disappear, both from the chart and from the drawing object format pop up.
- If I create a text object via Ctrl Left click and then use the keyboard, the text stays on the screen
- example use left & right arrow keys to scroll the chart
- I can also use moue in MultiCharts main menu (not on chart) and click Format -> Drawing Object and I can see the text object there. I can even select "format" from the popup window and change attributes of the text object, like color, size, font.
- once I click anywhere on the chart after this - it disappears and subsequest views of drawing objects popup does not have it listed.

Any Thoughts?

John Romero

This is part of my DGL Mouse indicator. I have included the entire code below if you want to run it.

Code: Select all

[ProcessMouseEvents = true] ;


Inputs: Inp_Lvl_0(0.0),
Inp_Lvl_1(0.125),
Inp_Lvl_2(0.238),
Inp_Lvl_3(0.382),
Inp_Lvl_4(0.5),
Inp_Lvl_5(0.618),
Inp_Lvl_6(0.786),
Inp_Lvl_7(0.875),
Inp_Lvl_8(1.0),
Inp_ColorSet0(red),
Inp_ColorSet1(green),
Inp_ColorSet2(cyan),
Inp_ColorSet3(yellow);

vars: JOR_0(0), JOR_1(0), JOR_Text("a3"),JOR_Date(0),JOR_Time(0),JOR_Bar(0);
Vars: JOR_Txt_Hndl(0);

{

This is my implementation of some aspects of Dynamic Gann Levels. using mouse events to recalculate.
I prefer to use fib ratios instead of 1/8s as the original DGL - you can change the input if you want.
I also did not implement any of the extentions fo the DGL levels greater than 1.0 -- like 1.32, 1.61,
I hope to use Mouse Events to select the points in the future. I'm currently having issues with Text_New and getting the MouseDateTime into values it will use.
You are welcome to use this code freely.
I used code originally created by Gregory Wood and it then had several modifications by others after that.

Usage: use the text tool to label swing high/lows with "a0", "b0" and "c0"
In its current implementation you can only have 4 sets of a-b-c's .a0-b0-c0 thru a3-b3-c3
The 2nd text character is what determines which 3 points belong to which DGL.
It will use the close for Point "a' and depending on the relationship of point "b" to "c", it will create a V (high - low - high) or inverted V DGL (low - high - low).
Then refresh the indicator by using Ctrl Left mouse click - This is to save you from having to cycle the status of the indicator from On - Off - On
When you press Ctrl Left Mouse Click - it will do a Recalculate.
As part of the initial calculation and recalculation it will delete any orphan text points.
Example you delete c3, but leave a3 and b3. These 2 will be deleted from the chart as part of the recalculation
You can delete any of the three ax, bx, or cx and it will delete the other 2 in that DGL group.
You can use the mouse to move a point and them Ctrl Left Mouse Click and it will redraw it for you.
I also automatically draw Andrews pitchfork, as that is what I wanted. You can go in and delete / comment that part of the code if you want
The color of each entire set of DGL lines (levels) is the same color, with the exception for DGL lvl = 0.5, that I color Magenta.
Line style of "dot" for the lower DGL levels, "solid" for higher.
Input selection for the values to use for the levels and colors for each DGL set of points.
I do not move the text like the original implementation did, as this will stack the text objects on the close/high/low and make it difficult to select or move them.

Use the pointer to move the labels to other points, then Ctrl Left Mouse Click to refresh.
You can display other groups of points by using labels "ax", "bx" and "cx",
where 'x' is 1, 2, or 3, e.g. "a3", "b3", "c3".
The DGL can overlap each other.

As this is a work in progress, there are some variables that I created and are not used.
When you look in the Switch/Case set of code, you can see where I am trying to figure out how to get MouseClickDateTime into the Date and Time parts of New_Text.
Once I get past that, I / You will be able to seelect the a-b-c points using Shift Left Mouse Click and not need to use the keyboard for anything.
Almost like a real drawing tool, except you can not move the set of lines as a whole / group.

Below is the log of the code before I stripped out what I didn't want and added other lines of code.
12/14/96 v1.0 - Initial distribution by Gregory Wood
12/16/96 v1.1 - Point A now uses the Close; projected TL's now extend right
01/08/97 v1.15 - Add customizable colors
01/10/97 v1.16 - Text placement logic now uses bar midpoint instead of close
01/13/97 v1.17 - Print values to log file
07/25/99 v1.18 - adapt to ts2k

John Romero
2012/07/01 - heaviliy modified / stripped original to use mouse events and removed things I did not want to speed it up.
}

switch (getappinfo(aicalcreason)) begin
case CalcReason_MouseLClick :
if MouseClickCtrlPressed then begin
JOR_0 = MouseClickDateTime;
print("mouse click date time --> ",MouseClickDateTime);
print("JOR_0 a simple numeric var--> ",JOR_0);
print("Left Ctrl -> Date portion of MouseDtTm = ", DateToString(IntPortion(JOR_0)));
print("Left Ctrl ->Time Portion of MouseDtTm = ", TimeToString(FracPortion(JOR_0)));
print("price --> ", MouseClickPrice);
JOR_Date = JulianToDate(IntPortion(JOR_0));
print("JOR_Date --> ", JOR_Date);
JOR_Time = DateTime2ELTime_s(JOR_0);
print("JOR_Time --> ", JOR_Time);
JOR_Txt_Hndl = text_new_s(JOR_Date,JOR_Time,MouseClickPrice,JOR_Text);
print("handle returned from Text_New_s --> ", JOR_Txt_Hndl);
JOR_0 = text_setcolor(JOR_Txt_Hndl, yellow);
print("return set color --> ", JOR_0);
JOR_0 = text_setsize(JOR_Txt_Hndl, 16);
print("return set size --> ",JOR_0);
if JOR_Text = "b3" then JOR_Text = "c3";
if JOR_Text = "a3" then JOR_Text = "b3";
print(" JORText --> ", JOR_Text);
end { if MouseClickCtrlPressed & CalcReason_MouseLClick }
else
if MouseClickShiftPressed then begin
// print("recacl");
// JOR_Recalc = 1;
recalculate;
end; { if MouseClickShiftPressed & CalcReason_MouseLClick }
case CalcReason_MouseRClick : // currently I do not use MouseRClick for anyting
if MouseClickCtrlPressed then begin
print("Right Ctrl ");
end { if MouseClickCtrlPressed & CalcReason_MouseRClick }
else
if MouseClickShiftPressed then begin
print("Right Shift ");
end; { if MouseClickShiftPressed & CalcReason_MouseRClick }

end;


if currentbar = 1 then begin { initialize control arrays }
array:abc[3](""); { The basic point labels }
abc[0] = "a";
abc[1] = "b";
abc[2] = "c";
array:nums[4](""); { The way to distinguish one series of points from another, a_b_c, a1-b1-c1, etc up to a3_b3_c3 }
nums[0] = "0";
nums[1] = "1";
nums[2] = "2";
nums[3] = "3";
var: inums(4);
array:DGL_Levels[9](0); { assign input levels to array for calculations in loops }
DGL_Levels[0] = Inp_Lvl_0;
DGL_Levels[1] = Inp_Lvl_1;
DGL_Levels[2] = Inp_Lvl_2;
DGL_Levels[3] = Inp_Lvl_3;
DGL_Levels[4] = Inp_Lvl_4;
DGL_Levels[5] = Inp_Lvl_5;
DGL_Levels[6] = Inp_Lvl_6;
DGL_Levels[7] = Inp_Lvl_7;
DGL_Levels[8] = Inp_Lvl_8;

array: colorset[4](tool_red);
colorset[0] = Inp_ColorSet0 ; { for series 0, A0B0C0 }
colorset[1] = Inp_ColorSet1 ; { for series 0, A1B1C1 }
colorset[2] = Inp_ColorSet2 ; { for series 0, A2B2C2 }
colorset[3] = Inp_ColorSet3 ; { for series 0, A3B3C3 }

end; { if currentbar = 1 }

array:dd[3,4](0),tt[3,4](0),vv[3,4](0),bb[3,4](0),hh[3,4](0);
{
dd --> array - holds the date value for each point
tt --> array - hold the time value for each point
vv --> array - holds the price value for each point
bb --> array - holds the bar # for each point
hh --> array - holds the handle value for each point
}
array: fb[4,8,4](0),fv[4,8,4](0); {fb[nums,lev,proj], fv[nums,lev,proj]}
array: han[4,8](0); // holds the handle for each drawn DGL trend line
array: Pt_B_High[4](0), Pt_B_Low[4](0);
var: tft(0), fdd(0), fvv(0), ptt(0), pdd(0), pvv(0), fbb(0), pbb(0), pvv2(0);
var: ii(0), jj(0), kk(0), mm(0);
{
ii --> is the index for looping through different ABC sets
jj --> is the index for looping through each A_B_C point in a DGL set of points
kk --> is the index for looping through each DGL level 0 - 8
fvv --> used to draw individual DGL lines in loop
fbb --> used to draw individual DGL lines in loop
pvv --> used to draw individual DGL lines in loop
}
var: handl(0); // holds current handle to drawing object
var: ss(""); // holds found text string to see if it is one we want


if currentbar = 1 then begin { examine all the text strings and save some info about the ones we recognize }
handl = text_getfirst(2);
while handl >= 0 begin
ss = text_getstring(handl);
for ii = 0 to inums - 1 begin
for jj = 0 to 2 begin { look for well-formed strings }
if ss = abc[jj] + nums[ii] then begin { save the item's date, time, value and handle }
tt[jj,ii] = text_gettime(handl);
dd[jj,ii] = text_getdate(handl);
vv[jj,ii] = text_getvalue(handl);
hh[jj,ii] = handl;
end; { if ss = abc[jj] + nums[ii] }
end; { for jj = 0 to 2 loop through search for A_B_C points in a DGL }
end; { for ii = 0 to inums - 1 loop through the groups of DGLs }
handl = text_getnext(handl,2); { IMPORTANT -- infinite loop if this is missing! }
end; { while handl >= 0 }

// Now that we have searched and recorded all "a_b_c" DGL points, make sure we have all 3
// If not make dd = 0 for all points of that DGL set and set hh - the pointer
for ii = 0 to inums - 1 begin
for jj = 0 to 2 begin { look for well-formed strings }
if dd[jj,ii] = 0 then begin { a missing point has been located - remove the other points }
dd[0,ii] = 0;
dd[1,ii] = 0;
dd[2,ii] = 0;
if hh[0,ii] > 0 then text_delete(hh[0,ii]); // attempt to delete all three text objects as well
if hh[1,ii] > 0 then text_delete(hh[1,ii]);
if hh[2,ii] > 0 then text_delete(hh[2,ii]);

end; { if dd[jj,ii] = 0 }
end; { for jj = 0 to 2 loop through search for A_B_C points in a DGL }
end; { for ii = 0 to inums - 1 loop through the groups of DGLs searching for missing A_B_C points }
end; { if currentbar = 1 }


for ii = 0 to inums - 1 begin { check each series... }
for jj = 0 to 2 begin { check each point }
if time = tt[jj,ii] and date = dd[jj,ii] then begin { we've found a selected point }
If jj = 0 then vv[0,ii] = close ; // point A of DGL is always close
If jj = 1 then begin
Pt_B_High[ii] = High;
Pt_B_Low[ii] = Low;
end;
bb[jj,ii] = currentbar; { remember where we found it -- bar # is used to calculate time between points }
if jj = 2 then begin { we're at the third point, Cx }
if vv[1,ii] > vv[2,ii] then begin
vv[1,ii] = Pt_B_High[ii];
vv[2,ii] = Low;
end
else begin
vv[1,ii] = Pt_B_Low[ii];
vv[2,ii] = High;
end;
for kk = 0 to 8 begin { examine each level }
fbb = bb[1,ii] * DGL_Levels[kk] + bb[2,ii] * (1 - DGL_Levels[kk]); // bars for point using B & C
fvv = vv[1,ii] * DGL_Levels[kk] + vv[2,ii] * (1 - DGL_Levels[kk]); // price for point using B&C
pvv = TLValue(vv[0,ii],bb[0,ii],fvv,fbb,currentbar);

han[ii,kk] = TL_New(dd[0,ii],tt[0,ii],vv[0,ii],date,time,pvv);
TL_SetExtRight(han[ii,kk],TRUE);
TL_SetColor(han[ii,kk], colorset[ii]);
if kk = 1 then
TL_SetStyle(han[ii,kk],3); { Make DGL lvl 1 line dotted .......... style = 3 }
if kk = 2 then
TL_SetStyle(han[ii,kk],3); { Make DGL lvl 2 line dotted .......... style = 3 }
if kk = 3 then
TL_SetStyle(han[ii,kk],3); { Make .382 DGL line dots ..... style = 3 }
if DGL_Levels[kk] = .5 then begin // usually kk = 4 is DGL level .5
TL_SetStyle(han[ii,kk],3); { Make .5 DGL line dots ....... style = 3 }
TL_SetColor(han[ii,kk], Magenta);
{ show the related trident channel }
pvv = TLValue(vv[1,ii],bb[1,ii],fvv+vv[1,ii]-vv[0,ii],fbb+bb[1,ii]-bb[0,ii],currentbar);
handl = TL_New(dd[1,ii],tt[1,ii],vv[1,ii],date,time,pvv);
TL_SetExtRight(handl,TRUE);
tl_setstyle(handl,2);
TL_SetColor(handl, colorset[ii]);
pvv = TLValue(vv[0,ii]-(fvv-vv[2,ii]),bb[0,ii]+(bb[2,ii]-fbb),vv[2,ii],bb[2,ii],bb[1,ii]);
handl = TL_New(dd[1,ii],tt[1,ii],pvv,date,time,vv[2,ii]);
TL_SetExtRight(handl,TRUE);
tl_setstyle(handl,2);
TL_SetColor(handl, colorset[ii]);

end; { if DGL_Levels[kk] = .5 }

end; { for kk = 0 to 8 }

end; {if jj = 2 }
end; { if time=tt[jj,ii] and date = dd[jj,ii] }
end; { for jj = 0 to 2 }
end; { for ii = 0 to inums-1}

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Why doesn't text appear on chart ? Not all the way righ

Postby JoshM » 02 Jul 2012

I can now get text to appear on the chart, but it does not stay there under some conditions.
Haven't tested it myself yet, but looking at your description and code, have you tried IntraBarPersist for the variables that will be updated intrabar?
that's not meant for you.
Ah okay. :)

johnromeronc
Posts: 53
Joined: 18 Feb 2011
Has thanked: 11 times
Been thanked: 13 times

Re: Why doesn't text appear on chart ? - I'm closerrrr

Postby johnromeronc » 02 Jul 2012

Josh,

I did set the variable (text) I am displaying with Text_New_S and I can change that after drawing and with IntraBarPersist, it now draws the 'new' text on the chart. But they still do not stay there. As soon as I either use another mouse 'click' it's gone. Also if the bar completes then the text disappears, even if I do not use the mouse.

I am guessing, it is an issue with Mouse Events implementation. I will create a bug report in PM.

Thanks for your efforts and time. I would not have gotten this far without you and TJ.

Man I love being a pioneer - the arrows and blood are just fun. Now if MultiCharts would let me create my own tools, then this would be a moot point. I know, I know - MC.NET Maybe I will go there next.

John

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Why doesn't text appear on chart ?

Postby bowlesj3 » 02 Jul 2012

but it does not stay there under some conditions. Should I submit this as a bug?
START: 2013/Feb/24th Update.
Regarding this post, a new [RecoverDrawings = false] parameter, has been created that is inserted in your power langauge scipt to solve this issue. See this link for more details.
viewtopic.php?f=1&t=11974&p=59597#p58425
END: 2013/Feb/24th Update.




Text, Trend Lines and Arrows will not remain until they are placed when Barstatus=2 (that is the last tick of the bar). So if 50 ticks come in during a bar and the first tick is when your first Text_new occurs then that text will be deleted on every next tick up until barstatus=2. Intrabarpersist will not help with this. In fact you should not use Intrabarpersist on the ID of the text. The only time you can be sure you have the correct ID to retain for the next bar is when BarStatus=2 and the Text_new has occurred at that time. These posts explain it. I am pretty sure I created a study to prove it was happening because the line is put on and removed very quickly when the next tick comes in. There is a simple set of code to correct it. If there are not too many of them, you can also create these on the first bar of the chart and hide them and show them when needed. That is almost all I do now. This way there is no need to have the delay code for waiting for the last tick of the bar. I have one script where I create 100 lines during the first bar of the chart and just show them when I need them.

This has the code to prove they are disappearing.
viewtopic.php?f=1&t=5329#p20202

Post 3 I think is the one that has code to retain the text on barstatus=2
viewtopic.php?f=5&t=6871

viewtopic.php?f=1&t=6785
Last edited by bowlesj3 on 24 Feb 2013, edited 1 time in total.

vking
Posts: 235
Joined: 21 May 2009
Has thanked: 51 times
Been thanked: 41 times

Re: Why doesn't text appear on chart ?

Postby vking » 02 Jul 2012

Observed this behavior with other text/trendline based studies I have built.

Trying to understand - if there is any technical reason for MC to delete and re-create it on every tick until barstatus=2. I can't think of a reason why MC is doing like this behind the scene - whether it is for text or trendlines.

Thanks
but it does not stay there under some conditions. Should I submit this as a bug?
Text, Trend Lines and Arrows will not remain until they are placed when Barstatus=2 (that is the last tick of the bar). So if 50 ticks come in during a bar and the first tick is when your first Text_new occurs then that text will be deleted on every next tick up until barstatus=2. Intrabarpersist will not help with this. In fact you should not use Intrabarpersist on the ID of the text. The only time you can be sure you have the correct ID to retain for the next bar is when BarStatus=2 and the Text_new has occurred at that time. These posts explain it. I am pretty sure I created a study to prove it was happening because the line is put on and removed very quickly when the next tick comes in. There is a simple set of code to correct it. If there are not too many of them, you can also create these on the first bar of the chart and hide them and show them when needed. That is almost all I do now. This way there is no need to have the delay code for waiting for the last tick of the bar. I have one script where I create 100 lines during the first bar of the chart and just show them when I need them.

This has the code to prove they are disappearing.
viewtopic.php?f=1&t=5329#p20202

Post 3 I think is the one that has code to retain the text on barstatus=2
viewtopic.php?f=5&t=6871

viewtopic.php?f=1&t=6785

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Why doesn't text appear on chart ?

Postby TJ » 02 Jul 2012

Observed this behavior with other text/trendline based studies I have built.

Trying to understand - if there is any technical reason for MC to delete and re-create it on every tick until barstatus=2. I can't think of a reason why MC is doing like this behind the scene - whether it is for text or trendlines.

Thanks
I have lots of text/trendlines in my charts, and this behavior has worked well for me.

The program must have a reference time -- a time to "freeze" the calculations and assign the variables to "history". The EOB (End of Bar) time is the EasyLanguage reference for all calculations (except for those that are declared intrabar specifics).

If you want a text/trendline to stay at an intrabar derived position,
All you have to do is use a variable that can capture the intrabar value, and hold that value until EOB

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Why doesn't text appear on chart ?

Postby ABC » 03 Jul 2012

Something that has been very useful for me in some studies is creating the Text-IDs needed at the end of the first bar and place them "out of sight". Then I can "grab" an existing text and only change it's locations and string when I need it, but don't suffer from the text vanishing with new ticks arriving.

I am using something like this

Code: Select all

once if Barstatus(1) = 2 then
begin
for kk = 0 to 99
begin
TextIDs[kk] = Text_New_S(Date, Time_S, 0, "");
Text_SetFontName(TextIDs[kk], FontName);
Text_SetSize(TextIDs[kk], FontSize);
Text_SetStyle(TextIDs[kk], HorizTxtPl, VertTxtPl);
//and other attributes needed...
end;

end;
and later, when I need a text, I alter it accordingly:

Code: Select all

Text_SetString(TextIDs[kk], MyString);
Text_SetLocation_S(TextIDs[kk], PlotDate, PlotTime, PlotPrice);
Regards,
ABC

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Why doesn't text appear on chart ?

Postby bowlesj3 » 03 Jul 2012

START: 2013/Feb/24th Update.
Regarding this post, a new [RecoverDrawings = false] parameter, has been created that is inserted in your power langauge scipt to solve this issue. See this link for more details.
viewtopic.php?f=1&t=11974&p=59597#p58425
END: 2013/Feb/24th Update.

Of all the solutions to this problem
1/creating the text,arrow,line on the first bar and moving it to viewable or hidden areas.
2/just keep redrawing it until barstatus=2 then storing your ID and stopping the redraws.
3/Flagging it for a single draw at the end of the bar when BarStatus=2.

#1 is by far both the easiest and the most efficient.

#2 can cause problems if your code has a bug and does not keep redraw it until BarStatus=2.
#2 can be a problem if you try to issue a delete to the ID before Barstatus=2 (may delete wrong line).
#2 can be a problem if you try to store the ID before BarStatus=2 (it could change)

#3 can be annoying with large bar sizes if you want to see the drawing object immediately.

So unless you have reason to use #2 or #3 then use #1.

I believe this behavior has to do with the old design related to the underlying tables. One of the links I created above has an attached document describing what I think is occuring with the updates of these underlying tables. It is probably because there was no intrabarpersist command originally and thus the ID for the drawing objects was getting clobbered on each new tick up until barstatus=2 (clobbered by the previous bars end of bar value) and thus they had to remove the drawing object since the ID would be wrong anyway. So when they created the Intrabarpersist they did not follow-up with a TL_New_Persist, Text_New_Persist and Arw_New_Persist. I have requested these commands in the PM system at the link below so if anyone has not voted for this I think everyone should since this problem creates a lot of waisted time for new users if they do not learn the above 3 techniques before they start coding. The old commands must remain so that old code still works but once these new commands were in place the Wiki should strongly recommend the use of the new commands where new code is being created.

NOTE:
Again, the new parameter [RecoverDrawings = false] was put in to resolve the issue above and replace the commands I requested. It is mentioned in the PM entry notes. It was put in MC 8.5.
TL_Persist, Text_Persist, Arw_Persist
https://www.multicharts.com/pm/viewissu ... _no=MC-436
Last edited by bowlesj3 on 21 Jan 2014, edited 3 times in total.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Why doesn't text appear on chart ?

Postby bowlesj3 » 24 Feb 2013

START: 2013/Feb/24th Update.
Regarding my posts to this thread, a new [RecoverDrawings = false] parameter, has been created that is inserted in your power langauge scipt to solve this issue with drawings being removed on each new tick until BarStatus=2. See this link for more details.
viewtopic.php?f=1&t=11974&p=59597#p58425
END: 2013/Feb/24th Update.


Return to “MultiCharts”