//+------------------------------------------------------------------+ //| 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); } //+------------------------------------------------------------------+