Using the function numtostring to plot the value of the maximum or minimum on the graph.
if you use numtostr (High, 2) the value appears correctly with decimals.
if I use input: decimal (x) and numtostr (High, decimal) the value is truncated without decimals.
someone knows why '?
thanks
numtostr function and decimals
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2223 times
Re: numtostr function and decimals
what value did you put in as "x" in decimal (x)?Using the function numtostring to plot the value of the maximum or minimum on the graph.
if you use numtostr (High, 2) the value appears correctly with decimals.
if I use input: decimal (x) and numtostr (High, decimal) the value is truncated without decimals.
someone knows why '?
thanks
- CrazyNasdaq
- Posts: 321
- Joined: 02 Sep 2009
- Location: ITALY
- Has thanked: 98 times
- Been thanked: 89 times
Re: numtostr function and decimals
Try this way, it will work:
input : decimal(2);
var : High_txt("");
high_txt=text(numtostr(h,decimal));
input : decimal(2);
var : High_txt("");
high_txt=text(numtostr(h,decimal));
Re: numtostr function and decimals
CrazyNasdaq,
where's the difference with
high_txt=text(numtostr(h,decimal));
and my proposal if you call the "text_var" later in a plot or text statement ? I don't see it.
An explanation would be nice, because I never used the text(......)-statement.
Thanks a lot.
Regards.
Mike
where's the difference with
high_txt=text(numtostr(h,decimal));
and my proposal if you call the "text_var" later in a plot or text statement ? I don't see it.
An explanation would be nice, because I never used the text(......)-statement.
Thanks a lot.
Regards.
Mike
- CrazyNasdaq
- Posts: 321
- Joined: 02 Sep 2009
- Location: ITALY
- Has thanked: 98 times
- Been thanked: 89 times
Re: numtostr function and decimals
the function "numtostr" transforms a numeric value into a string.
If you assign to a variable a Text statement as High_Txt(""), it must be already a text.
With this trick, using Text(numtostr(valueA, decimals)) you force the code the get the right implementation.
Try that way and it will not be truncated.
If you assign to a variable a Text statement as High_Txt(""), it must be already a text.
With this trick, using Text(numtostr(valueA, decimals)) you force the code the get the right implementation.
Try that way and it will not be truncated.
Re: numtostr function and decimals
So you are saying if I have to implement variable text into the code, then it is necessary to implement numtostr-functions into your text(....) proposal ?
With all respect your note :
It is not necessary that high_txt("") is already a text, because var : high_txt("") already defined it as text. Therefore we have this numtostr-function, which able us to transform numerical values into string.
I'm always working like this :
Thanks a lot.
Regards.
Mike
With all respect your note :
in my experience is wrong.If you assign to a variable a Text statement as High_Txt(""), it must be already a text.
With this trick, using Text(numtostr(valueA, decimals)) you force the code the get the right implementation.
It is not necessary that high_txt("") is already a text, because var : high_txt("") already defined it as text. Therefore we have this numtostr-function, which able us to transform numerical values into string.
I'm always working like this :
May your style to define it is working well, but with my way I get the same result. I will test your way tomorrow in real-time and will check for any improvements system wise.
var: txtr1("")
var: min1rid(-1);
txtr1=" minHExp. "+numtostr(....,autodecimals)+" > "+numtostr(....,autodecimals);
if min1rid<0 then begin
min1rid=text_new(date,time,....,txtr1);
text_setstyle(min1rid,0,2);
text_setcolor(min1rid,text_color);
text_setsize(min1rid,text_size);
end
else
begin
text_setstring(min1rid,txtr1);
text_setlocation(min1rid,date,calctime(time+(2*barinterval),1),....);
text_setcolor(min1rid,text_color);
text_setsize(min1rid,text_size);
end;
Thanks a lot.
Regards.
Mike
- CrazyNasdaq
- Posts: 321
- Joined: 02 Sep 2009
- Location: ITALY
- Has thanked: 98 times
- Been thanked: 89 times
Re: numtostr function and decimals
You are right, but you wrote that you get a truncated string.
I use "numtostr" as you write too, but using "text" you can solve that bug/problem.
It was simply a solution, but you can write your code the way you prefer.
Regards
I use "numtostr" as you write too, but using "text" you can solve that bug/problem.
It was simply a solution, but you can write your code the way you prefer.
Regards