Inverting double value

Back to topics list To post a new topic, please log in or register
avatar
11
fx_matt 2016.02.07 11:53
 

Part of my indicator uses USDCHF open price inverted to give CHFUSD open value which normally is 1/USDCHF.

My indicator is working on one or two time frames but on others I am getting an error "zero divide" and it is pointing to this line of code? 

double   Quote = 1/ iOpen(EnumToString(QuoteCurrency),0,i); 

Is there another way to invert the USDCHF open value to stop this error? 

avatar
Moderator
3423
GumRai 2016.02.07 12:17 #
 
EnumToString(QuoteCurrency) is not a valid symbol, why don't you simply use "USDCHF"?
avatar
11
fx_matt 2016.02.07 13:06 #
 
GumRai:
EnumToString(QuoteCurrency) is not a valid symbol, why don't you simply use "USDCHF"?

Sorry EnumToString(QuoteCurrency) is an input I sometimes also use USDCAD

input   ENUM_FX_PAIRS  QuoteCurrency = USDCHF; 

avatar
13008
WHRoeder 2016.02.07 15:16 #
 
Since iOpen(EnumToString(QuoteCurrency),0,i) is returning zero, find out why. Print _Symbol and EnumToString(QuoteCurrency) and _LastError.
avatar
11
fx_matt 2016.02.07 15:57 #
 

Thanks 

I got 4051 not sure why?

ERR_INVALID_FUNCTION_PARAMETER_VALUE4051Invalid function parameter value.

 

 

 

avatar
13008
WHRoeder 2016.02.07 21:11 #
 
How should we know? You didn't show the function parameter value(s)
avatar
Moderator
3423
GumRai 2016.02.08 00:55 #
 
fx_matt:

Sorry EnumToString(QuoteCurrency) is an input I sometimes also use USDCAD

input   ENUM_FX_PAIRS  QuoteCurrency = USDCHF; 

That is the problem with using names that do not describe the variable

Print out  EnumToString(QuoteCurrency), and make sure that it is a valid symbol (as WHRoeder has already said.)

Many brokers use a prefix or suffix and USDCHF will not be recognised. 

avatar
125
zirkoner 2016.02.09 22:38 #
 
GumRai:

That is the problem with using names that do not describe the variable

Print out  EnumToString(QuoteCurrency), and make sure that it is a valid symbol (as WHRoeder has already said.)

Many brokers use a prefix or suffix and USDCHF will not be recognised. 

Interesting, do you know a broker which use a prefix ?
Back to topics list  

To add comments, please log in or register