Mql5 | How can i call the last indicator signal? - page 2

 
As I wrote the buffer (an array) is filled by CopyBuffer and how to access an array is described in the a. m. articles.
 
Carl Schreiber #:
As I wrote the buffer (an array) is filled by CopyBuffer and how to access an array is described in the a. m. articles.

Thank you, i am began to understand now a little.


In this code i create copybuffer and array, but still can't access array after reading article because of i am a beginner and my English language is too bad


can you refer me to the line in the article that enable me to access the array?

I searched in google but i have confused

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2

#property indicator_type1 DRAW_NONE
#property indicator_width1 3
#property indicator_color1 0xFF901E
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_NONE
#property indicator_width2 3
#property indicator_color2 0xFF00FF
#property indicator_label2 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

double myPoint;
double Open[];
double Close[];
double Low[];
double High[];
int SAR_handle;
double SAR[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int OnInit()
  {
   SetIndexBuffer(0, Buffer1);
   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, EMPTY_VALUE);
   SetIndexBuffer(1, Buffer2);
   PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, EMPTY_VALUE);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3|| Digits() == 2|| Digits() == 4)
     {
      myPoint *= 10;
     }
     
   SAR_handle = iSAR(NULL, PERIOD_CURRENT, 0.034, 0.2);
   if(SAR_handle < 0)
     {
      Print("The creation of iSAR has failed: SAR_handle=", INVALID_HANDLE);
      Print("Runtime error = ", GetLastError());
      return(INIT_FAILED);
     }
   
   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;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, EMPTY_VALUE);
      ArrayInitialize(Buffer2, EMPTY_VALUE);
     }
   else
      limit++;
   datetime Time[];
   
   
   if(BarsCalculated(SAR_handle) <= 0) 
   return(0);
   if(CopyBuffer(SAR_handle, 0, 0, rates_total, SAR) <= 0) return(rates_total);
   ArraySetAsSeries(SAR, true);
   if(CopyOpen(Symbol(), PERIOD_CURRENT, 0, rates_total, Open) <= 0) return(rates_total);
   ArraySetAsSeries(Open, true);
   if(CopyClose(Symbol(), PERIOD_CURRENT, 0, rates_total, Close) <= 0) return(rates_total);
   ArraySetAsSeries(Close, true);
   if(CopyLow(Symbol(), PERIOD_CURRENT, 0, rates_total, Low) <= 0) return(rates_total);
   ArraySetAsSeries(Low, true);
   if(CopyHigh(Symbol(), PERIOD_CURRENT, 0, rates_total, High) <= 0) return(rates_total);
   ArraySetAsSeries(High, true);
   if(CopyTime(Symbol(), Period(), 0, rates_total, Time) <= 0) return(rates_total);
   ArraySetAsSeries(Time, true);
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
if (i >= MathMin(200000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation         
//Indicator Buffer 1
if(true)
{

}
else
{
Buffer1[i] = EMPTY_VALUE;
}
//Indicator Buffer 2
if(true)
{

}
else
{
Buffer2[i] = EMPTY_VALUE;
}

}
return(rates_total);
  }
 
Carl Schreiber #:
As I wrote the buffer (an array) is filled by CopyBuffer and how to access an array is described in the a. m. articles.

Can i use this loop to do what i am looking for?


for( int k = 1+2; k |= 1+30; k++ )


I want to make sure

if SAR value of candle 1 is above High value of candle 1 &&  SAR value of candle 2 is below Low value of candle 2

or  SAR value of candle 2 is above High value of candle 2  &&  SAR value of candle 3 is below Low value of candle 3

..... to candle number 30??