Displaying the current price above the current candle

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
duration
Posts: 179
Joined: 20 Dec 2005
Been thanked: 1 time

Displaying the current price above the current candle

Postby duration » 05 Oct 2010

Hello,

Is there any indicator available in Multicharts that display the current price, in big letters and in bold, on the right of the current candle, and that makes the text green when there is an uptick and red when there is a downtick?

Many thanks,

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: Displaying the current price above the current candle

Postby arnie » 05 Oct 2010

Hi duration.

I decided to give it a try on your request :oops:
It's a way for me to train my lack of programmer skills :P

Code: Select all

if currentbar = 1 then begin
value1 = text_new(date, time, 0, "");
text_setstyle(value1, 0, 2);
Text_SetSize(value1, 24);
end;

if LastBarOnChart then begin
value2 = close;
Text_SetString(value1, " " + NumToStr(value2, 2));
end;

Text_SetLocation(value1, Date, Time, value2);

if upticks > downticks then
Text_SetColor(value1, green)
else
if downticks < upticks then
Text_SetColor(value1, red)
else
if upticks = downticks then
Text_SetColor(value1, white);
There are a couple of issues with the code.
First I couldn't make it turn green or red on each respective received tick. I tried to change colours when upticks were higher or lower than the downticks, but even here I had problems with it.

Let's hope one of the experts can shine some light on it.

Regards,
Fernando

duration
Posts: 179
Joined: 20 Dec 2005
Been thanked: 1 time

Re: Displaying the current price above the current candle

Postby duration » 05 Oct 2010

Hello Arnie,

Thank you for your reply.

Here is what I wrote:

Code: Select all

variables: lastprice(0);

if barstatus = 1 then begin
lastprice = text_new(date,time+1,close,text(close:0:4));
text_setattribute(lastprice,1,true);
text_setfontname(lastprice,"Calibri");
text_setsize(lastprice,12);
text_setstyle(lastprice,2,2);
text_setcolor(lastprice,white);
end;
I agree it is difficut to make the price green for an uptick and red for a downtick..

In addition, I cannot find a way for the displayed price to stay right of the candle, it gradually moves left as time elapses...

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

Re: Displaying the current price above the current candle

Postby TJ » 06 Oct 2010

the trick is to use text_setlocation to re-position the text to the last bar (ie. current bar).

see attached sample code.
Attachments
Last Price.txt
(544 Bytes) Downloaded 455 times

duration
Posts: 179
Joined: 20 Dec 2005
Been thanked: 1 time

Re: Displaying the current price above the current candle

Postby duration » 08 Oct 2010

Hi TJ,

Thank you for your code.

However the price still displays on the far right, and gradually comes back as time elapses... is there no way of having a "stable" location with Powerlanguage?

Many thanks,

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

Re: Displaying the current price above the current candle

Postby TJ » 08 Oct 2010

Hi TJ,

Thank you for your code.

However the price still displays on the far right, and gradually comes back as time elapses... is there no way of having a "stable" location with Powerlanguage?

Many thanks,
are you sure you are using my code?

or maybe you are using the code in a sub-minute chart?

duration
Posts: 179
Joined: 20 Dec 2005
Been thanked: 1 time

Re: Displaying the current price above the current candle

Postby duration » 08 Oct 2010

Hi TJ,

Well spotted, I am using the code with a 4 point chart.

Is this a problem?

Many thanks,

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

Re: Displaying the current price above the current candle

Postby TJ » 08 Oct 2010

Hi TJ,

Well spotted, I am using the code with a 4 point chart.

Is this a problem?

Many thanks,
you have to change the following keywords:

text_new
text_setlocation
time

to

text_new_s
text_setlocation_s
time_s

duration
Posts: 179
Joined: 20 Dec 2005
Been thanked: 1 time

Re: Displaying the current price above the current candle

Postby duration » 11 Oct 2010

Hi TJ,

Thank you! This does it.

No idea on how to make the price colour change to green or red when there is an uptick or downtick?

Many thanks,

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

Re: Displaying the current price above the current candle

Postby TJ » 11 Oct 2010

Hi TJ,

Thank you! This does it.

No idea on how to make the price colour change to green or red when there is an uptick or downtick?

Many thanks,
Where There is a Will, There is a Way...
Attachments
Last Price b03.txt
(941 Bytes) Downloaded 494 times

duration
Posts: 179
Joined: 20 Dec 2005
Been thanked: 1 time

Re: Displaying the current price above the current candle

Postby duration » 12 Oct 2010

Hi TJ,

Thanks a lot!

close < or > lastprice is very smart, I was stuck with up & down ticks.

It works perfectly now.

Thanks again and take care,

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

Re: Displaying the current price above the current candle

Postby TJ » 12 Oct 2010

Hi TJ,

Thanks a lot!

close < or > lastprice is very smart, I was stuck with up & down ticks.

It works perfectly now.

Thanks again and take care,
yw

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

Re: Displaying the current price above the current candle

Postby TJ » 12 Oct 2010

Hi TJ,

Thanks a lot!

close < or > lastprice is very smart, I was stuck with up & down ticks.

It works perfectly now.

Thanks again and take care,
What you required is the uptick/downtick compared to the previous tick.

but the keywords (note the "s")
UpTicks refers to the total number of Up ticks for the current bar.
DownTicks refers to the total number of Down ticks for the current bar.


Return to “User Contributed Studies and Indicator Library”