I know MarketInfo returns a double value 0, so the statement "case 0 " may mismatch thinking it is a integer .. - I'm not sure .
Any help appreciated as I know it is something small ...
As you suspected, You could have tried casting it to an int before posting :)
Switch - " Expression of the switch operator must be of integer type."
I tried this and it worked but I looked up casting and it seems I cannot turn a double into an int.
I just want to understand this before I close out even though I have fixed the issue .. ( hacking it out ) .
int test = (MarketInfo(Symbol(),MODE_PROFITCALCMODE)); switch(test)
What I understand :
" Each variant of case can be marked with an integer constant, a literal constant or a constant expression"
Ok so this means you cannot use doubles which makes sense ( decimal places issue ) . SOo my expression above seems to have converted a double number to an Integer yet the casting URL says otherwise ..
Any clarification appreciated.
The documentation does not have the greatest wording :) I think the casts indicated by bold arrows can be done implicitly by the compiler and it wont complain as there is no risk of losing some of the number.
Otherwise, I think, you can explicitly cast numbers to any other numeric type you want as long as you are aware you can possibly lose information.In which case some of those arrows should be bi-directional or diagram re-drawn somehow?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I was slowly Compiling my EA's into build610 worthy EA's.
This part of my code came unstuck where Build590 was fine ( see below switch statement )
The error is : 'MarketInfo' - illegal switch expression '
What I know -
I know MarketInfo returns a double value 0, so the statement "case 0 " may mismatch thinking it is a integer .. - I'm not sure .
Any help appreciated as I know it is something small ...