Display the last value of an indicator  [SOLVED]

Questions about MultiCharts and user contributed studies.
mickatrade
Posts: 114
Joined: 12 Jul 2015
Has thanked: 20 times
Been thanked: 16 times

Display the last value of an indicator

Postby mickatrade » 05 Jan 2016

Hello,
I'm trying to display the spread on my chart, the problem is, it shows a value for each candle.
How can i display it, only for the last candle.

here is my code :

Code: Select all

variable : monhigh(0);

if LastBarOnChart then begin

monhigh = getappinfo(aihighestdispvalue);

value1 = text_new(date, time,monhigh, "Spread: " & numtostr((CurrentAsk-CurrentBid),3));
Value1 = Text_SetColor(value1 ,black);

print (PriceScale);

end;
Thanks
Attachments
spread.JPG
spread indicator
(125.57 KiB) Downloaded 586 times

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

Re: Display the last value of an indicator

Postby arnie » 05 Jan 2016

Hello,
I'm trying to display the spread on my chart, the problem is, it shows a value for each candle.
How can i display it, only for the last candle.
didn't test this but try something like:

Code: Select all

variable : monhigh(0);

once begin
value1 = text_new(date, time,monhigh, "Spread: " & numtostr((CurrentAsk-CurrentBid),3));
Value1 = Text_SetColor(value1 ,black);
end;

if LastBarOnChart then begin
monhigh = getappinfo(aihighestdispvalue);
print (PriceScale);
end;

mickatrade
Posts: 114
Joined: 12 Jul 2015
Has thanked: 20 times
Been thanked: 16 times

Re: Display the last value of an indicator  [SOLVED]

Postby mickatrade » 05 Jan 2016

Thx arnie,

Your code actually doesn't work but it's helped me to correct mine.

Below, my working code :

Code: Select all

variable : monhigh(0),idtext(0);

once begin
idtext = text_new(date, time,monhigh, "Spread: ");
Value1 = Text_SetColor(idtext ,black);
end;


if LastBarOnChart then begin

monhigh = getappinfo(aihighestdispvalue);
value1 = text_setlocation(idtext,date,time,monhigh);
value1 = text_setstring(idtext,"Spread: " & numtostr(0.1*pricescale*(CurrentAsk-CurrentBid),1) & "pips");

end;
Attachments
workingspread.png
(41.62 KiB) Downloaded 588 times


Return to “MultiCharts”