numtostr help

chrisleonard

Junior member
Messages
13
Likes
0
I am making an indicator and im stuck on something small (i hope)

here is the code

variables:
Decimals( Log(PriceScale) / Log(10) ),
decimal(0),
ID(-1);

Value1 = XAverage( close, 200 ) ;

if decimals = 2 then decimal = 10;
if decimals = 3 then decimal = 100;
if decimals = 4 then decimal = 1000;
if decimals = 5 then decimal = 10000;


if Value1 > Value1[1] then begin
ID = Text_New(D,T,L-Range, "movement: " + numtostr(ATR,decimals) );
end;

the part coloured red needs to be multiplied by 1000 before its plotted but needs to be done with the number of decimals i have coded!

so ID = Text_New(D,T,L-Range, "movement: " + numtostr(ATR*10000,decimals) will not work it needs to be

ID = Text_New(D,T,L-Range, "movement: " + numtostr(ATR,decimals) *10000 somehow.

Any help much appriciated!
 
I am not Bill Gates but it seems to me that you are converting (ATR,Decimals to a string. A string =text and therefore cannot be multiplied by a number. try converting (ATR,Decimals back to a number. Or if it fits what you want then try

ID * 10000.

Hope that helps
Nut
 
wow nut u the man for the quick reply :)

Where do i define ID * 10000???

or how can i convert ATR, decimals back to a number

i was thinking

ATRD = ATR bla bla bla with code to change decimal places here??
 
Text_New(D,T,L-Range, "movement: " + numtostr(ATR,decimals) *10000

I suspect that all of the above line of code is actually a string.

Therefore try numtostr(ID) * 10000

Good luck
Nut
 
What if you replace numtostr(ATR,decimals) in the text string by

numtostr(ATR*DECIMAL, DECIMALS)

Charlton
 
What if you replace numtostr(ATR,decimals) in the text string by

numtostr(ATR*DECIMAL, DECIMALS)

Charlton

It might work as it will convert decimals to a string representaion ie text. However you then still need to convert from text back to a number at some point. therefore you need to find the correct function to do that, perhaps it is strtonum, search your help files. When this works the answer obtained ie the number requires careful checking to ensure you are getting the correct results every time.

keep trying
Nut
 
It might work as it will convert decimals to a string representaion ie text. However you then still need to convert from text back to a number at some point. therefore you need to find the correct function to do that, perhaps it is strtonum, search your help files. When this works the answer obtained ie the number requires careful checking to ensure you are getting the correct results every time.

keep trying
Nut
Why does he need to convert the text back to a number. The bit in red is designed to put some text on the chart in a position related to the bar. If he wants to plot ATR then that already exists as a number

Charlton
 
Why does he need to convert the text back to a number. The bit in red is designed to put some text on the chart in a position related to the bar. If he wants to plot ATR then that already exists as a number

Perhaps you know more than me, however he still wishes to muliply a string by a number which if I am correct will not works as the types are perhaps incompatible. If you have a better solution the please post. If the objective is to display "SOME STRING ON SCREEN" + ATR*10000 then complete the mathematical function first ie ATR *10000. Then convert the answer to a string ie variable =numtostr(answer).
Then concatinate the two strings (SOME STRING ON SCREEN + ANSWER).

Cheers Nut
 
Why does he need to convert the text back to a number. The bit in red is designed to put some text on the chart in a position related to the bar. If he wants to plot ATR then that already exists as a number

Perhaps you know more than me, however he still wishes to muliply a string by a number which if I am correct will not works as the types are perhaps incompatible. If you have a better solution the please post. If the objective is to display "SOME STRING ON SCREEN" + ATR*10000 then complete the mathematical function first ie ATR *10000. Then convert the answer to a string ie variable =numtostr(answer).
Then concatinate the two strings (SOME STRING ON SCREEN + ANSWER).

Cheers Nut

Nut

This goes back to earlier posts for example

http://www.trade2win.com/boards/tradestation/74648-realtime-indicator-help-el.html#post917074

You are correct in your second part that he wants to multiply the ATR by a factor, which depends upon whether the instrument is forex or an index if I recall correctly. He also wants to vary the number of decimal points displayed. As you say the numeric value has to be multiplied by the relevant factor before conversion to a string. Then during conversion to a string the relevant number of decimal places need to be input

So numtostr(ATR*DECIMAL, DECIMALS) within the text_new command will multiply the numeric ATR by the numeric variable called DECIMAL e.g. 100. numtostr will then convert that value into text and it will display the text version of the number with the value of DECIMALS e.g 3

Charlton
 
I am not familiar with the capabilities of the language employed, however logically each function needs to be completed individually before conversion to a string and then concatination.
There may be a very simple way of doing this in one step in which case the person coding needs to find the correct functions within the help files, I do not know them.

Therefore firstly
NewAtr =ATR * 10000
Secondly
CorrectedDecimals = SetDecimals(NewAtr,2) or whatever the correct function coding is.
Thirdly
Convertednum=Numtostr(CorrectedDecimals)
Lastly

Sometextonscreen+Convertednum

Thats about the limit of my knowledge I hope it works.

Cheers
Nut
 
Top