Library not returning the correct value

 

Hi all, 

I've been writing a function in mql5 and at the moment all I want it to do is return a value of a double (max_value). However, it only seems to be returning a value of -1! Could somebody help me debug this?


Thank you!

double max_val_max_candle_price_range_function(int no_candle_limit) export
  {

   double max_value = 1;
   double min_value = 0.5;
   /*
//Creates a struct where the information about the candles (e.g. price) will be stored.
   MqlRates PriceInfo[];
//Sorts it from the current candle to the oldest candle
   ArraySetAsSeries(PriceInfo,true);
//Copies the price information into the array
   double Data=CopyRates(Symbol(),PERIOD_CURRENT,0,Bars(Symbol(),PERIOD_CURRENT),PriceInfo);

//Creating 'buy' arrays
   double close_price[]; //Store the close price
   ArrayResize(close_price,no_candle_limit);
   double open_price[]; //Store the close price
   ArrayResize(open_price,no_candle_limit);

   for(int i=0; i<no_candle_limit; i=i+1)
     {
      close_price[i]=PriceInfo[i+1].close;
      open_price[i]=PriceInfo[i+1].open;
     }
   
   double price_target=(open_price[0]+close_price[0])/2;
   int counter=0;

   for(int i=1;i<no_candle_limit;i=i+1)
     {
      if(open_price[i]>=close_price[i] && price_target<=open_price[i] && price_target>=close_price[i])
        {
         break;
        }
      if(open_price[i]>=close_price[i] && (price_target>open_price[i] || price_target<close_price[i]))
        {
         counter=counter+1;
        }
      if(open_price[i]<close_price[i] && price_target>=open_price[i] && price_target<=close_price[i])
        {
         break;
        }
      if(open_price[i]<close_price[i] && (price_target<open_price[i] || price_target>close_price[i]))
        {
         counter=counter+1;
        }

     }

   double candle_price_range = counter/no_candle_limit;
   double max_val_max_norm_candle_price_range = (candle_price_range-min_value)/(max_value-min_value);
   */
   
   return min_value;

  }
//+------------------------------------------------------------------+