Page 1 of 1

Simple code to print a string on the lesft side of a chart

Posted: 21 May 2012
by arjfca
Hello

Here is few line of code to print a string, at a defined price a string. For the purpose of this post, I included the string and the price position As an input value.

For me I will use the code to create horizontal trendline to display few key point on the chart.

Code: Select all

//aiLeftDispDateTime
Input:
InputPrice (1.2800),
TextToPrint ("This is a test");

Var:
DateTimeFirstBar (0),
sdate (0),
sTime (0),
sPrice (0),
Left.Date (0),
left.time(0),
TextH1 (0);

DateTimeFirstBar = getappinfo(aiLeftDispDateTime);

If barstatus[1] = 2 then begin
Value1 = text_delete(TextH1);
left.date = juliantodate( getappinfo( aileftdispdatetime ) );
Left.time = (datetime2eltime_s(getappinfo( aileftdispdatetime )) );
Print (Left.Date, " ", left.time);

TextH1= Text_New_S(Left.date,Left.time,InputPrice, " TextToPrint");
Value2 = text_setstyle(TextH1,0,1);
Value2 = Text_SetColor(TextH1,Red);

end;
Martin

Re: Simple code to print a string on the lesft side of a cha

Posted: 21 May 2012
by TJ
Hello

Here is few line of code to print a string, at a defined price a string. For the purpose of this post, I included the string and the price position As an input value.

For me I will use the code to create horizontal trendline to display few key point on the chart.

Code: Select all

//aiLeftDispDateTime
Input:
InputPrice (1.2800),
TextToPrint ("This is a test");

Var:
DateTimeFirstBar (0),
sdate (0),
sTime (0),
sPrice (0),
Left.Date (0),
left.time(0),
TextH1 (0);

DateTimeFirstBar = getappinfo(aiLeftDispDateTime);

If barstatus[1] = 2 then begin
Value1 = text_delete(TextH1);
left.date = juliantodate( getappinfo( aileftdispdatetime ) );
Left.time = (datetime2eltime_s(getappinfo( aileftdispdatetime )) );
Print (Left.Date, " ", left.time);

TextH1= Text_New_S(Left.date,Left.time,InputPrice, " TextToPrint");
Value2 = text_setstyle(TextH1,0,1);
Value2 = Text_SetColor(TextH1,Red);

end;
Martin
please review this line

barstatus[1] = 2

Re: Simple code to print a string on the lesft side of a cha

Posted: 22 May 2012
by arjfca
please review this line

barstatus[1] = 2
Hello TJ


This will fire the code at the beginning of the last new bar.

- Barstatus[1] = 2 will proceeed the code at the beginning of a bar
- Barstatus = 2 will proceed the code at the last ending thick of a bar.

In that case, either will work since no calculation is done on the value of the last bar.

Martin :)