Need Help Putting Text On Chart

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
flipflopper
Posts: 261
Joined: 28 Feb 2008
Has thanked: 2 times
Been thanked: 1 time

Need Help Putting Text On Chart

Postby flipflopper » 10 Dec 2008

I have two moving averages for my 30 minute chart... they are the 65 and 130 period SMA.

In reality they are the 5 and 10 day moving average.

Is there a way to add text after each moving average calling them a 5 day and 10 day?

User avatar
TJ
Posts: 7380
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2110 times

Postby TJ » 11 Dec 2008

where do you want to add the text?

can you post a chart?

flipflopper
Posts: 261
Joined: 28 Feb 2008
Has thanked: 2 times
Been thanked: 1 time

Postby flipflopper » 11 Dec 2008

See attached
Attachments
sampletext.png
(26.18 KiB) Downloaded 1176 times

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:

Cut and Paste

Postby RobotMan » 11 Dec 2008

This should get you pointed in the right direction. It is kinda generic. You will need to use the code twice in the same indicator and rename the vars. You will probably want to use "ver 2".

Code: Select all

inputs:
Price(Close),
Length(20)
//, TText("My Avg") <-- ver 2
;

vars:
SpacerTxt(" "),
MAval(C), MAref(-1) ;

MAval = Average(Price,Length);

Plot1(MAval,"MovAvg");

If MAref <> -1 Then Text_SetLocation_s(MAref, Date, Time_s, MAval)
Else Begin
MAref = Text_New_s(Date, Time_s, MAval, SpacerTxt + NumToStr(MAval ,2) );
// MAref = Text_New_s(Date, Time_s, MAval, SpacerTxt + TText ); <-- ver 2
Text_SetStyle(MAref, 0, 2);
Text_SetColor(MAref, GetPlotColor(1));
End;
Attachments
MA with Text.txt
(511 Bytes) Downloaded 434 times
Last edited by RobotMan on 11 Dec 2008, edited 1 time in total.

User avatar
TJ
Posts: 7380
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2110 times

Postby TJ » 11 Dec 2008

I have added a bonus for you.

enjoy!

TJ
Attachments
avg_w_text.txt
(1.58 KiB) Downloaded 449 times

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:

Postby RobotMan » 11 Dec 2008

TJ: Snazzy!

I was looking at what I posted and I thought:
It's funny how, when composing a post in the "reply window", everything is formatted and indented really nice and easy to read, but when you hit the submit button, the final post looks like sh!t.
Too bad we can attach everything but .pla files huh.

User avatar
TJ
Posts: 7380
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2110 times

Postby TJ » 11 Dec 2008

TJ: Snazzy!

I was looking at what I posted and I thought:
It's funny how, when composing a post in the "reply window", everything is formatted and indented really nice and easy to read, but when you hit the submit button, the final post looks like sh!t.
Too bad we can attach everything but .pla files huh.
to format your code, you have to use the code button...
it is located in the middle of the Format list.
(you will see it when you are composing your message)

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:

Postby RobotMan » 11 Dec 2008

Hi TJ

Nice. I edited my post and it looks better. Thanks!
I wish I could reduce the code font size though....

flipflopper
Posts: 261
Joined: 28 Feb 2008
Has thanked: 2 times
Been thanked: 1 time

Postby flipflopper » 11 Dec 2008

Thanks for the help guys!!

User avatar
TJ
Posts: 7380
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2110 times

Postby TJ » 11 Dec 2008

I have done one better... now with Auto-text.

The MA length is automatically inserted into the text... no need to adjust the text when you change your MA length.

enjoy!
Attachments
avg_w_autotext.txt
(1.69 KiB) Downloaded 466 times

flipflopper
Posts: 261
Joined: 28 Feb 2008
Has thanked: 2 times
Been thanked: 1 time

Postby flipflopper » 11 Dec 2008

Very nice TJ. Thanks!!


Return to “User Contributed Studies and Indicator Library”