Not all control paths return a value !

 

Hi all,

I've converted this code from mq4 to mq5

and I'm getting one error that I couldn't get rid off.

It is "'}' - not all control paths return a value"

Please help. Thanks in advance.

#property copyright "Me"
#property link      "Me@gmail.com"
//----
#property indicator_chart_window
#property indicator_plots 1
#property indicator_buffers 1
#property indicator_color1 Blue

//----

double Size[];
double High[],Low[],Open[],Close[];

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
int OnInit()
  {
  //:::::::::::::::::::::::::::::::::::::::::::::
  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  int Bars=Bars(Symbol(),PERIOD_CURRENT);
  double Point=Point();


   SetIndexBuffer(0, Size);
   PlotIndexSetInteger(0,PLOT_ARROW,150);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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[])
{
  //:::::::::::::::::::::::::::::::::::::::::::::
  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  int Bars=Bars(Symbol(),PERIOD_CURRENT);
  double Point=Point();
  //Etc.
  //:::::::::::::::::::::::::::::::::::::::::::::::

  if(Period()!=PERIOD_H4) return(0);
  if(Symbol()!= "EURUSD") return(0);
  
  double Length,Body;
  for(int i = 0; i < Bars; i++)
  {
    Length=(High[i]-Low[i])/Point;
    Body=MathAbs(Close[i]-Open[i])/Point;
    if(Length<=90 && Body>=Length*0.70)
    {
      Size[i] = Low[i] - 15 * Point;
    }
   
  }
}

 
The OnCalculate() function has type int so it has to return a value. In your source code the return operator has been missed.
Documentation on MQL5: Language Basics / Functions / Event Handling Functions
  • www.mql5.com
Language Basics / Functions / Event Handling Functions - Documentation on MQL5
 

i've add  return(rates_total); thanks Rosh

and now , no errors :)

but the code is not doing anything !


Reason: