
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

double CrossUp[];
double CrossDown[];
extern int FasterEMA = 10;
extern int SlowerEMA = 20;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_HISTOGRAM);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_HISTOGRAM);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i;
double fasterEMAnow, slowerEMAnow;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++) {

fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i);

slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i);

CrossUp[i] = 0; CrossDown[i] = 0;

if (fasterEMAnow > slowerEMAnow) {
CrossUp[i] = 1;
}
else if (fasterEMAnow < slowerEMAnow) {
CrossDown[i] = -1;
}
}
return(0);
}