Page 1 of 1

Displaying the current price above the current candle

Posted: 05 Oct 2010
by duration
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,

Re: Displaying the current price above the current candle

Posted: 05 Oct 2010
by arnie
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

Re: Displaying the current price above the current candle

Posted: 05 Oct 2010
by duration
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...

Re: Displaying the current price above the current candle

Posted: 06 Oct 2010
by TJ
the trick is to use text_setlocation to re-position the text to the last bar (ie. current bar).

see attached sample code.

Re: Displaying the current price above the current candle

Posted: 08 Oct 2010
by duration
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,

Re: Displaying the current price above the current candle

Posted: 08 Oct 2010
by TJ
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?

Re: Displaying the current price above the current candle

Posted: 08 Oct 2010
by duration
Hi TJ,

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

Is this a problem?

Many thanks,

Re: Displaying the current price above the current candle

Posted: 08 Oct 2010
by TJ
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

Re: Displaying the current price above the current candle

Posted: 11 Oct 2010
by duration
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,

Re: Displaying the current price above the current candle

Posted: 11 Oct 2010
by TJ
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...

Re: Displaying the current price above the current candle

Posted: 12 Oct 2010
by duration
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,

Re: Displaying the current price above the current candle

Posted: 12 Oct 2010
by TJ
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

Re: Displaying the current price above the current candle

Posted: 12 Oct 2010
by TJ
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.