'}' - not all control paths return a value - MetaEditor 5.00 Build 883

 

What is the problem causing this error message?

MetaEditor 5.00 Build 883 / MetaTrader 4 Build 604

//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
input color    FontColor=clrLime;
input string   FontName="Arial";
input string   Corner="UpperLeft=0, UpperRight=1, LowerLeft=2, LowerRight=3";
input int      CornerNumber=1;
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   TextLabel("multi1", Symbol() + "," + Per(Period()), 18, FontName, FontColor, 138, 37, CornerNumber);
   TextLabel("multi2", "Q u o t e / B a s e , P e r i o d", 8, FontName, FontColor, 31, 37, CornerNumber);
   TextLabel("multi3", "Bid(Sell): ", 10, FontName, FontColor, 4, 49, CornerNumber);
   TextLabel("multi4", "Ask(Buy): ", 10, FontName, FontColor, 4, 63, CornerNumber);
   TextLabel("multi5", "Spread: ", 10, FontName, FontColor, 5, 80, CornerNumber);
   
   return(rates_total);
  }
//+------------------------------------------------------------------+
void TextLabel(string Name, string Text, int Size, string Font, color Color, int x, int y, int iCorner)
   {
   ObjectCreate(Name,OBJ_LABEL,0,0,0);
   ObjectSetText(Name,Text,Size,Font,Color);
   ObjectSet(Name,OBJPROP_XDISTANCE,x);
   ObjectSet(Name,OBJPROP_YDISTANCE,y);
   ObjectSet(Name,OBJPROP_CORNER,iCorner); 
   }  
//+------------------------------------------------------------------+  
string Per(int thisperiod)
   {
   if(thisperiod==1){return("M1");}
   if(thisperiod==5){return("M5");}
   if(thisperiod==15){return("M15");}
   if(thisperiod==30){return("M30");}
   if(thisperiod==60){return("H1");}
   if(thisperiod==240){return("H4");}
   if(thisperiod==1440){return("D1");}
   if(thisperiod==10080){return("W1");}
   if(thisperiod==43200){return("MN1");}
   }
//+------------------------------------------------------------------+
 

Forum on trading, automated trading systems and testing trading strategies


Hello,

This forum is about MT5/mql5, please post your question about MT4/mql4 on mql4.com forum.

  • They are more people who can answer there.
  • They are more people who can have similar problem there.
  • A forum is not only to get help but to share with the community, mql4/MT4 community isn't the same as mql5/MT5 community.

 
Subgenius:

What is the problem causing this error message?

MetaEditor 5.00 Build 883 / MetaTrader 4 Build 604

Problem is here :

string Per(int thisperiod)
   {
   if(thisperiod==1){return("M1");}
   if(thisperiod==5){return("M5");}
   if(thisperiod==15){return("M15");}
   if(thisperiod==30){return("M30");}
   if(thisperiod==60){return("H1");}
   if(thisperiod==240){return("H4");}
   if(thisperiod==1440){return("D1");}
   if(thisperiod==10080){return("W1");}
   if(thisperiod==43200){return("MN1");}
returned value ?
    }

You declare a function which should return a string, but what if all "if" are false ?

 
angevoyageur:

Problem is here :

You declare a function which should return a string, but what if all "if" are false ?

By the way, maybe Subgenius must literally switch to a switch case statement (https://www.mql5.com/en/docs/basis/operators/switch) and use default label.
Documentation on MQL5: Language Basics / Operators / Switch Operator
Documentation on MQL5: Language Basics / Operators / Switch Operator
  • www.mql5.com
Language Basics / Operators / Switch Operator - Documentation on MQL5
Reason: