Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network speeds up calculations. Try it!
Keith Watford
Moderator
9553
Keith Watford 2015.02.06 02:39  
darelco:

... in this part of code is a problem with new compilation (error ---> 'MarketInfo' - illegal switch expression type) perhaps it was all OK until the update to MT4 build 600+ ... but since then it doesn't work any longer.

 So, could you please post some newer version ... if  of course you're still around.


I think if you change

                switch ( MarketInfo( strSymbol, MODE_DIGITS ) )

 to

                int dig=MarketInfo( strSymbol, MODE_DIGITS ) ;
                switch ( dig )

 It will compile ok

Alain Verleyen
Moderator
30297
Alain Verleyen 2015.02.06 09:07  
darelco:

... in this part of code is a problem with new compilation (error ---> 'MarketInfo' - illegal switch expression type) perhaps it was all OK until the update to MT4 build 600+ ... but since then it doesn't work any longer.

 So, could you please post some newer version ... if  of course you're still around.


   switch((int)MarketInfo(strSymbol,MODE_DIGITS))
gadget
100
gadget 2015.02.06 10:00  

https://book.mql4.com/operators/switch

"The values of Expression and of Parameters can only be the values of int type. The Expression can be a constant, a variable, a function call, or an expression. Each variation 'case' can be marked by an integer constant, a character constant, or a constant expression. A constant expression cannot include variables or function calls."

Keith Watford
Moderator
9553
Keith Watford 2015.02.06 11:18  
angevoyageur:
   switch((int)MarketInfo(strSymbol,MODE_DIGITS))

Once again, you come up with a simpler and better solution.
Alain Verleyen
Moderator
30297
Alain Verleyen 2015.02.06 11:39  
GumRai:
Once again, you come up with a simpler and better solution.
We all learn from each other.
whroeder1
14241
whroeder1 2015.02.06 13:12  
                int dig=MarketInfo( strSymbol, MODE_DIGITS ) ;
                switch ( dig )
or
   switch((int)MarketInfo(strSymbol,MODE_DIGITS))
or the object style (works except for pointer casts)
   switch( int(MarketInfo(strSymbol,MODE_DIGITS)) )
/ /1234
To add comments, please log in or register