Get the precious value of MACD.

 

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?

 
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.

 

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.

 
NoCool14:

I don't know if that is the right way

definitely not the right way :-)
 
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 . . .
 
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?

 
GumRai:


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


no, only by DoubleToString not DoubleToStr
 
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

 

the doc's says otherwise my mistake sorry

another reason not to read them ;-)

 
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.
 
qjol:

no, only by DoubleToString not DoubleToStr

Doesn't both means the same?
Reason: