double risk; string pairall[8]={"SGDJPY","NZDUSD","AUDUSD","CADJPY","USDJPY","CHFJPY","EURUSD","GBPUSD"}; string lotall[8]; string spreadall[8]; string pairM[4]={"NZDUSD","AUDUSD","USDJPY","EURUSD"}; string lotM[4]; string spreadM[4]; int i, j; string mytext, mytextM; int start() { risk = GlobalVariableGet("risk"); i=0; mytext="With risk ="+DoubleToStr(risk,2)+"\r \r symbol lot spread"; while(i<ArrayRange(pairall,0)) { lotall[i] = DoubleToStr(risk*AccountFreeMargin()/MarketInfo(pairall[i],MODE_MARGINREQUIRED),2); spreadall[i] = DoubleToStr(MarketInfo(pairall[i],MODE_SPREAD)/10,1); mytext=mytext+"\r "+pairall[i]+" "+lotall[i]+" "+spreadall[i]; i++;} j=0; mytextM="\r"; while(j<ArrayRange(pairM,0)) { lotM[j] = DoubleToStr(risk*AccountFreeMargin()/MarketInfo(pairM[j],MODE_MARGINREQUIRED),2); spreadM[j] = DoubleToStr(MarketInfo(pairM[j],MODE_SPREAD)/10,1); mytextM=mytextM+"\r "+pairM[j]+" "+lotM[j]+" "+spreadM[j]; j++;} MessageBox(mytext+mytextM,NULL,EMPTY); return(0); }
Wow, that's the only thing missing?! Thank you very much! I suppose I can fix that way all my scripts. Perfect!
hello everyone please help to fix this:
bool orderprofit()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if((OrderType()==OP_BUY && OrderOpenPrice()<Bid ) || (OrderType()==OP_SELL && OrderOpenPrice()>Ask))
return(True);
else
return(False);
}
}
}
but give me this error ""not all control paths return a value""
hello everyone please help to fix this:
bool orderprofit()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if((OrderType()==OP_BUY && OrderOpenPrice()<Bid ) || (OrderType()==OP_SELL && OrderOpenPrice()>Ask))
return(True);
else
return(False);
}
}
}
but give me this error ""not all control paths return a value""
Because it doesn't return anything when orderselect fails.
bool orderprofit() { for(int i=OrdersTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if((OrderType()==OP_BUY && OrderOpenPrice()<Bid ) || (OrderType()==OP_SELL && OrderOpenPrice()>Ask)) return(True); } } return(False); }
Because it doesn't return anything when orderselect fails.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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, I moved to new computer and was forced to install a new built of MT4 way above 600. Almost all my compiled scripts are working, but those that don't return the same error: "not all control paths return a value". In theory I understnad what it might mean, but with my basic programming skills I can't find where exactly am I missing some cases and why before it was alright. for example this script below doesn't even have if-else in it and still returns the same error:
Please help e to fix it.