Hi,
Could anybody please check the code - that return error : "illegal switch expression type" and "'0.01' - constant expression is not integral".
the code was working in old version.
Thanks a lot for help
Expression of the switch operator must be of integer type
Hi,
Could anybody please check the code - that return error : "illegal switch expression type" and "'0.01' - constant expression is not integral".
the code was working in old version.
Thanks a lot for help
Expression of the switch operator must be of integer type
Hi Keith,
Thanks, If integer used then no then it doesn't show error. As the operator hold decimal so double used. Integer will work for that for decimal ?
Hi Keith,
Thanks, If integer used then no then it doesn't show error. As the operator hold decimal so double used. Integer will work for that for decimal ?
I don't know what you are asking.
You cannot use a double, only int and uint.
I have deleted your other topic as it is a repeat of this topic and you have already been answered.
MarketInfo() returns a double so you were once again using a double with switch().
The variable names suggest that you are working with decompiled code.
If you post decompiled code, it will be deleted and you could be banned from the forum.
... and just in case you didn't read it before the other topic was deleted: -log10(step) is the simple answer
Could you show me the way of using -log10(step) for the following code -
int init() { trD = MarketInfo(Symbol(), MODE_SPREAD) * Point; if (IsTesting() == TRUE) Display_Info(); // TRUE if (IsTesting() == FALSE) Display_Info(); // FALSE int step = MarketInfo(Symbol(), MODE_LOTSTEP); switch(step) { case 0.01:Lotdecimal_0_1_2 = 2; break; case 0.1 : Lotdecimal_0_1_2 = 1; break; case 1 : Lotdecimal_0_1_2 = 0; break; } if (Digits == 5 || Digits == 3) val_1= 10; return (0); }
int init() { trD = MarketInfo(Symbol(), MODE_SPREAD) * Point; if (IsTesting() == TRUE) Display_Info(); // TRUE if (IsTesting() == FALSE) Display_Info(); // FALSE double step = MarketInfo(Symbol(), MODE_LOTSTEP); Lotdecimal_0_1_2=-log10(step); if (Digits == 5 || Digits == 3) val_1= 10; return (0); }
not tested and I use MQL5 only, but this should work with MQL4, too, because it is basic calculus:
-log10(0.01)=2
-log10(0.1)=1
-log10(1)=0
just be aware, that log doesn't return valid numbers for values <=0
[edit: sorry, didn't see that "step" was declared as an integer --> now corrected
btw: the declaration of "step" doesn't even appear necessary, so even shorter:
int init() { trD = MarketInfo(Symbol(), MODE_SPREAD) * Point; if (IsTesting() == TRUE) Display_Info(); // TRUE if (IsTesting() == FALSE) Display_Info(); // FALSE Lotdecimal_0_1_2=-log10(MarketInfo(Symbol(), MODE_LOTSTEP); if (Digits == 5 || Digits == 3) val_1= 10; return (0); }
]
int step = MarketInfo(Symbol(), MODE_LOTSTEP);
MarketInfo() returns a double.
You should always use
#property strict
then you will get a warning about the double being implicitly cast as an integer.
MarketInfo() returns a double.
You should always use
then you will get a warning about the double being implicitly cast as an integer.
Thanks Keith for supporting
not tested and I use MQL5 only, but this should work with MQL4, too, because it is basic calculus:
-log10(0.01)=2
-log10(0.1)=1
-log10(1)=0
just be aware, that log doesn't return valid numbers for values <=0
[edit: sorry, didn't see that "step" was declared as an integer --> now corrected
btw: the declaration of "step" doesn't even appear necessary, so even shorter:
]
Thank YOU Chris that really helpful
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Could anybody please check the code - that return error : "illegal switch expression type" and "'0.01' - constant expression is not integral".
the code was working in old version.
Thanks a lot for help