Dear Coders, this coding showing error
'MarketInfo' - illegal switch expression type
please rectify this
You can try adding the (int) as switch() only works with integer type expressions
switch (MarketInfo(symbol,MODE_PROFITCALCMODE))
{
switch ((int)MarketInfo(symbol,MODE_PROFITCALCMODE)) {
switch (MarketInfo(symbol,MODE_PROFITCALCMODE)) { case 0: { int sbar=iBarShift(symbol,0,tbar); size=MarketInfo(symbol,MODE_LOTSIZE); if (StringSubstr(symbol,3,3)=="USD") break; if (StringSubstr(symbol,0,3)=="USD") size=size/iClose(symbol,0,sbar); else { BQ=StringSubstr(symbol,0,3)+"USD"; if (iClose(BQ,0,0)==0) BQ="USD"+StringSubstr(symbol,0,3); if (iClose(BQ,0,0)==0) break; int BQbar=iBarShift(BQ,0,tbar); if (StringSubstr(BQ,0,3)=="USD") size=size/iClose(BQ,0,BQbar)/iClose(symbol,0,sbar); else size=size*iClose(BQ,0,BQbar)/iClose(symbol,0,sbar); } } break; case 1: size=MarketInfo(symbol,MODE_LOTSIZE); break; case 2: size=MarketInfo(symbol,MODE_TICKVALUE)/MarketInfo(symbol,MODE_TICKSIZE); }
Marketinfo returns a double.
switch ((int)MarketInfo(symbol,MODE_PROFITCALCMODE)) { case 0: { int sbar=iBarShift(symbol,0,tbar); size=MarketInfo(symbol,MODE_LOTSIZE); if (StringSubstr(symbol,3,3)=="USD") break; if (StringSubstr(symbol,0,3)=="USD") size=size/iClose(symbol,0,sbar); else { BQ=StringSubstr(symbol,0,3)+"USD"; if (iClose(BQ,0,0)==0) BQ="USD"+StringSubstr(symbol,0,3); if (iClose(BQ,0,0)==0) break; int BQbar=iBarShift(BQ,0,tbar); if (StringSubstr(BQ,0,3)=="USD") size=size/iClose(BQ,0,BQbar)/iClose(symbol,0,sbar); else size=size*iClose(BQ,0,BQbar)/iClose(symbol,0,sbar); } } break; case 1: size=MarketInfo(symbol,MODE_LOTSIZE); break; case 2: size=MarketInfo(symbol,MODE_TICKVALUE)/MarketInfo(symbol,MODE_TICKSIZE); }
Why did you post this again when you had already been answered?
Double posting wastes peoples time. Do you think that Marco would have taken the time to reply if he knew that I had already given you the answer?
I will delete your other post and move the reply here.
- Don't double post! You already had this thread open.
General rules and best pratices of the Forum. - General - MQL5 programming forum - There is no MarketInfo in MT5.
Market Info - Reference on algorithmic/automated trading language for MetaTrader 5Why did you post your MT4 question in the Root / MT5 Indicators section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon.
- 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 Dear Coders,
any one can please solve this error
'MarketInfo' - illegal switch expression type.