Download MetaTrader 5

Get the precious value of MACD.

To add comments, please log in or register
NoCool14
239
NoCool14  

Hello guys,

It might be a stupid question but here it goes:

I have a double variable MACDcurrent and I call the iMACD function and I get 0 as a return, but when I do DoubleToStr I get 0.000123. How can I get that procession stored into my variable?


double MACDcurrent =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); // returns 0

Print(DoubleToStr(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0))); // returns 0.000123


Am I doing something wrong?

SYED NAUFAL GADDAFI
1399
SYED NAUFAL GADDAFI  
double MACDcurrent =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); // returns 0

Print(DoubleToStr(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0))); // returns 0.000123


How bout ...

Print(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0));

?


Please use SRC button besides video button by the way.

NoCool14
239
NoCool14  

Sorry about that...

Thanks for the reply.

I found a work around. I multiply the result from iMACD by a big integer(100000000) and then I get all the numbers I need after the decimal point and then if I divide that number by the same multiplier and I get the correct procession I need. I don't know if that is the right way, but it works.

qjol
3243
qjol  
NoCool14:

I don't know if that is the right way

definitely not the right way :-)
Simon Gniadkowski
Moderator
18025
Simon Gniadkowski  
NoCool14:

Hello guys,

It might be a stupid question but here it goes:

I have a double variable MACDcurrent and I call the iMACD function and I get 0 as a return, but when I do DoubleToStr I get 0.000123. How can I get that procession stored into my variable?


double MACDcurrent =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); // returns 0

Print( DoubleToStr( iMACD( NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0 )     ) ); // returns 0.000123


Am I doing something wrong?

Yes you are, DoubleToStr() takes 2 parameters, you are just passing one . . .
Keith Watford
Moderator
10651
Keith Watford  
RaptorUK:
Yes you are, DoubleToStr() takes 2 parameters, you are just passing one . . .


Seems that if the 2nd parameter is not passed, then it will default to 8 digits.

NoCool14:

Hello guys,

It might be a stupid question but here it goes:

I have a double variable MACDcurrent and I call the iMACD function and I get 0 as a return, but when I do DoubleToStr I get 0.000123. How can I get that procession stored into my variable?


double MACDcurrent =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); // returns 0

Print(DoubleToStr(iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0))); // returns 0.000123


Am I doing something wrong?


So I believe that your Print would have returned "0.00012300"

Did you not see Deysmacro's post? How do you determine that

double MACDcurrent =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); 

returns 0. Why not Print MACDcurrent?

qjol
3243
qjol  
GumRai:


Seems that if the 2nd parameter is not passed, then it will default to 8 digits.


no, only by DoubleToString not DoubleToStr
Keith Watford
Moderator
10651
Keith Watford  
qjol:

no, only by DoubleToString not DoubleToStr
   double a =0.000123;
   Print("a = ",a);
   string a1=DoubleToStr(a);
   Print("a1 = ",a1);

2014.03.31 05:58:44.515 a1 AUDCAD,M5: a = 0.000123

2014.03.31 05:58:44.515 a1 AUDCAD,M5: a1 = 0.00012300

qjol
3243
qjol  

the doc's says otherwise my mistake sorry

another reason not to read them ;-)

Keith Watford
Moderator
10651
Keith Watford  
qjol:

the doc's says otherwise my mistake sorry

another reason not to read them ;-)


Yes, but it is still better to do it correctly, maybe it defaults to 8 now, but maybe not in a future build.
SYED NAUFAL GADDAFI
1399
SYED NAUFAL GADDAFI  
qjol:

no, only by DoubleToString not DoubleToStr

Doesn't both means the same?
12
To add comments, please log in or register