//+------------------------------------------------------------------+
//|                                           OC_ntst_с периодом.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//+----
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_width1 2
#property indicator_style1 0
double BufferOC_CP[];
//-----------
extern int x_prd =4;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
    SetIndexBuffer(0,BufferOC_CP);//
    SetIndexStyle(0,DRAW_LINE);//cтиль 0-№буфера
   return(INIT_SUCCEEDED);
   
//---
   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[])
  {
//--- return value of prev_calculated for next call
 
   for (int i=0; i<Bars; i++)
   {//есть буфер в котором складываем значения
    BufferOC_CP[i]=((Open[i]+Close[i])/2);//High[i];
   }


   return(rates_total);
   
  }
//+------------------------------------------------------------------+
