Guppy MMA oscillator

Author: mladen
Guppy MMA oscillator
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites
Guppy MMA oscillator
//+------------------------------------------------------------------+
//|                                          Guppy MMA oscilator.mq4 |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  LimeGreen
#property indicator_color2  Red
#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

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---