Max Min and retration Fibonacci intraday

 

hi, could you help me how to get maximum and minimum, from daily timeframe, using mqlrates does not work.

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   5

#property indicator_type1   DRAW_LINE
#property indicator_type2   DRAW_LINE
#property indicator_type3   DRAW_LINE
#property indicator_type4   DRAW_LINE
#property indicator_type5   DRAW_LINE

#property indicator_color1  Red
#property indicator_color2  Red
#property indicator_color3  Blue
#property indicator_color4  Blue
#property indicator_color5  Blue

#property indicator_label1  "Max"
#property indicator_label2  "Min"
#property indicator_label3  "38.2%"
#property indicator_label4  "50%"
#property indicator_label5  "61.8%"

//--- indicator buffers
double    ExtHighBuffer[];
double    ExtLowBuffer[];
double    ExtMiddBuffer[];
double    ExtMidd38Buffer[];
double    ExtMidd61Buffer[];

double Max[], Min[];

MqlRates rates[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtHighBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtLowBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtMiddBuffer,INDICATOR_DATA);
   SetIndexBuffer(3,ExtMidd38Buffer,INDICATOR_DATA);
   SetIndexBuffer(4,ExtMidd61Buffer,INDICATOR_DATA);

  }
//+------------------------------------------------------------------+
//| Price Channell                                                   |
//+------------------------------------------------------------------+
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[])
  {
  
   //CopyRates(_Symbol, PERIOD_D1, 0, 100, rates);
  
   if(rates_total<1)
      return(0);

   int start;
//--- preliminary calculations
   if(prev_calculated==0)
      start=1;
   else
      start=prev_calculated-1;
//--- the main loop of calculations
   for(int i=start; i<rates_total && !IsStopped(); i++)
     {
      CopyRates(_Symbol, PERIOD_D1, 0, 100, rates);
      
      //Max and Min
      ExtHighBuffer[i]        = high[i];     // try rates[i].high don´t work
      ExtLowBuffer[i]         = low[i];      // try rates[i].low don´t work
	
      //retrations
      ExtMiddBuffer[i]        = ExtHighBuffer[i] - ((ExtHighBuffer[i] - ExtLowBuffer[i]) * 0.5);  
      ExtMidd38Buffer[i]      = ExtHighBuffer[i] - ((ExtHighBuffer[i] - ExtLowBuffer[i]) * 0.382);
      ExtMidd61Buffer[i]      = ExtHighBuffer[i] - ((ExtHighBuffer[i] - ExtLowBuffer[i]) * 0.618);
      
     }
//--- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }
 

You have to put the "CopyRates" line outside the loop.

First copy everything, then add the changes.