Did something change?

 

I have some code that returns the number of digits for the specific currency pair that I use to convert my pips to add/subtract from the price. Until now it has worked without any problem but since yesterday I am experiencing problems with one of the results. Where the variable CalcPoint should return the value .01 it now returns .0 and I cannot understand why. The other result is correct as .0001. Did something change which I am not aware of with the Yen pairs that have only 3 digits?

Here is the code:

double PipPoint(string Currency)
        {
                int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
                if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
                else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
                return(CalcPoint);
        }
 

You may be passing an incorrect Currency (spelling mistake, missing a prefix or suffix) - I'd check that carefully.

Use GetLastError() when you return a value of 0 and see if the error code is 4106.

if(CalcPoint<=0) { Print(GetLastError()); }

 

I'd also strongly recommend you use 

#property strict

It would pick up on some incorrect style you have in there.

You only declare CalcPoint within the first condition. So if the second condition is true, you have an undeclared identifier. And when you return it.

Also, MarketInfo returns a double but you have declared CalcDigits as an integer. You could typecast it, but personally I'd be using SymbolInfoInteger() instead.

 

Thanks a lot for your help. I do have #property strict enabled but got no errors on that part of the code.

I changed the declaration of the variable double CalcPoint from being part of the code to the start of the program where I declare all my global variables - and that solved the problem! You comments helped me to see this as a possible error.

Thanks again!

 

Hello ernest02, I'm glad you got it sorted.

I think you may want to revisit your #property strict, as that code should not compile without warnings and errors in you truly are using the strict directive:


Reason: