#property indicator_chart_window
#property indicator_buffers 1
double CCI[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,CCI,INDICATOR_DATA);
//---
return(0);
}
//+------------------------------------------------------------------+
//| 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;
int i;
int counted_bars=prev_calculated;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=rates_total-counted_bars;
//---- cci counted in the buffer
CCI=iCCI(NULL,0,14,PRICE_CLOSE);
for(int i=0; i<limit; i--)
{
if ((CCI[i-1]<0)&&
(CCI[i-2]>0));
{
Alert ("TEST");
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+