Author: Copyright � 2011, MetaQuotes Software Corp.
Indicators Used
Bill Williams AlligatorMoving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
AllMA

//+------------------------------------------------------------------+
//|                                                        AllMA.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
extern int AllMAper=10;
int start()
  {
   int limit;
   int    counted_bars=IndicatorCounted();
//----
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
   //for(int i=0; i<limit; i++)
     // ExtMapBuffer1[i]=AllMA(AllMAper, i);
   AllEMA(AllMAper);
   AllEMA2(AllMAper);
      
      //MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//----
   return(0);
  }
//+------------------------------------------------------------------+
double len(double dot1, double dot2, double shift)
{
   //return(MathSqrt(shift*shift+(dot1-dot1)*(dot2-dot1))*Point);
   return((dot2-dot1));
}

double AllMA(int Per, int shift)
{
   int i;
   double sum;
   double Jaws, Teeth, Lips;
   for (i=0; i<Per; i++)
   {
      Jaws=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORJAW, Per+shift);  
      Teeth=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORTEETH, Per+shift);
      Lips=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORLIPS, Per+shift);
      sum=(len(Jaws, Teeth, 1)+len(Teeth, Lips, 1))*Volume[shift];
      //sum=MathAbs(Jaws-Teeth)+MathAbs(Teeth-Jaws);
   }
   return(sum/Per);
}

double AllEMA(int Per)
{
   double pr=2.0/(Per+1);
   int    pos=Bars-Per;
   double Jaws, Teeth, Lips, sum;
   
   //if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
//---- main calculation loop
   while(pos>=0)
     {
      Jaws=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORJAW, pos);  
      Teeth=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORTEETH, pos);
      Lips=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORLIPS, pos);
      sum=len(Jaws, Teeth, Per*3)+len(Teeth, Lips, Per*2);
      if(pos==Bars-Per) ExtMapBuffer1[pos+1]=AllMA(Per, Per);
      ExtMapBuffer1[pos]=sum*pr+ExtMapBuffer1[pos+1]*(1-pr);
 	   pos--;
     }
   
}

double AllEMA2(int Per)
{
   int    pos=Bars-Per;
   double Jaws, Teeth, Lips, sum;
   
   //if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
//---- main calculation loop
   while(pos>=0)
     {
      Jaws=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORJAW, pos);  
      Teeth=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORTEETH, pos);
      Lips=iAlligator(NULL, NULL, 13, 8, 8, 5, 5, 3, MODE_EMA, PRICE_MEDIAN, MODE_GATORLIPS, pos);
      sum=(Jaws+Teeth+Lips)/3;
      ExtMapBuffer2[pos]=iMA(NULL, 0, Per/3, 0, MODE_EMA, PRICE_CLOSE, pos)-sum;
 	   pos--;
     }
}

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 ---