#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_width1 1
#property indicator_color2 Red
#property indicator_width2 1
#property indicator_color3 Yellow
#property indicator_width3 1
extern int Fperiod=12;
extern int Speriod=26;
extern int Method=3;
extern int PRICE_MODE=PRICE_CLOSE;
extern int Display=100;
double Buf0[];
double Buf1[];
double Buf2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE);
IndicatorDigits(Digits+1);
SetIndexBuffer(0,Buf0);
SetIndexBuffer(1,Buf1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(2,Buf2);
SetIndexStyle(2,DRAW_LINE);
IndicatorShortName("Proba");
return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
int start()
{
int cbi, IC=Bars-IndicatorCounted()+1;
if (IC<2) cbi=IC; else {if (Display==0) cbi=Bars-Speriod-1; else cbi=Display;}
for(int i=cbi; i>=0; i--)
Buf0=iMA(NULL,0,Fperiod,0,Method,PRICE_MODE,i)-iMA(NULL,0,Speriod,0,Method,PRICE_MODE,i);
for(i = cbi; i >= 0; i--)
{
Buf2 = Buf0;
Buf1 = Buf0;
if (Buf0 > Buf0[i+1])
{
Buf2 = EMPTY_VALUE;
Buf1[i+1] = Buf0[i+1];
}
else
{
Buf1 = EMPTY_VALUE;
Buf2[i+1] = Buf0[i+1];
}
}
return(0);
}
//+---------------------------------