# Get the precious value of MACD.

239

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?

1399

```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.

239

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.

3243

NoCool14:

I don't know if that is the right way

definitely not the right way :-)
Moderator
18025

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 . . .
Moderator
10651

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?

3243

GumRai:

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

no, only by DoubleToString not DoubleToStr
Moderator
10651

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

3243

the doc's says otherwise my mistake sorry

another reason not to read them ;-)

Moderator
10651

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.
1399

qjol:

no, only by DoubleToString not DoubleToStr

Doesn't both means the same?