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

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

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

Postby arjfca » 21 May 2012

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

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

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

Postby TJ » 21 May 2012

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

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

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

Postby arjfca » 22 May 2012

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 :)


Return to “User Contributed Studies and Indicator Library”