My indicator does not plot on the mql5 chart

 
Hello friends, I try to create a parabolic sar indicator, and it should draw a line, the problem is that the code does not give me errors but it does not show anything on the graph either, I use candles for 1 to 5 minutes.

Can you help me and tell me where I am failing please?

//+------------------------------------------------------------------+
//|                                                     Pruebas6.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Sar
#property indicator_label1  "Sar"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrAqua
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         SarBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int handle1;


int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,SarBuffer,INDICATOR_DATA);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---   
      
   handle1=iSAR(_Symbol,_Period,0.02,0.2);
   int limit = rates_total-prev_calculated;
   
   double temp_buffer1[];
   
   CopyBuffer(handle1,0,0,limit+1,temp_buffer1);
   //double num;
   for(int i=limit-1; i>=0; i--)
   {    
    SarBuffer[i]=temp_buffer1[i];     
   }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


 
Hi,

The handling should be done in the OnInit() function.

//+------------------------------------------------------------------+
//|                                                     Pruebas6.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Sar
#property indicator_label1  "Sar"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrAqua
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         SarBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int handle1;


int OnInit()
  {
//--- indicator buffers mapping
SetIndexBuffer(0,SarBuffer,INDICATOR_DATA);

handle1=iSAR(_Symbol,_Period,0.02,0.2);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
//---   
      
   int limit = rates_total-prev_calculated;
   
   double temp_buffer1[];
   
   CopyBuffer(handle1,0,0,limit+1,temp_buffer1);
   //double num;
   for(int i=limit-1; i>=0; i--)
   {    
    SarBuffer[i]=temp_buffer1[i];     
   }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Pruebas6
Files:
Pruebas6.mq5  5 kb
Reason: