//+------------------------------------------------------------------+
//| Guppy MMA oscilator.mq4 |
//| mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link "mladenfx@gmail.com"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Gold
#property indicator_level1 0
#property indicator_levelcolor DarkSlateGray
//
//
//
//
//
extern int Price = PRICE_CLOSE;
extern int SignalPeriod = 13;
//
//
//
//
//
double buffer1[];
double buffer2[];
double periods[]={3,5,8,10,12,15,30,35,40,45,50,60};
int persize;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,buffer1);
SetIndexBuffer(1,buffer2);
persize =ArraySize(periods);
return(0);
}
int deinit() { return(0); }
//
//
//
//
//
int start()
{
double alpha = 2.0/(1.0+SignalPeriod);
int counted_bars=IndicatorCounted();
int i,limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = Bars-counted_bars;
//
//
//
//
//
for(i=limit; i>=0; i--)
{
double sum = 0;
for(int j=0; j<persize; j++)
{
if (periods[j]<30)
sum += iMA(NULL,0,periods[j],0,MODE_EMA,Price,i);
else sum -= iMA(NULL,0,periods[j],0,MODE_EMA,Price,i);
}
buffer1[i] = sum*10.0;
buffer2[i] = buffer2[i+1]+alpha*(buffer1[i]-buffer2[i+1]);
}
return(0);
}
Comments