Fibo-Average

Fibo-Average
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Fibo-Average
/*------------------------------------------------------------------+
 |                                                Fibo-Average.mq4  |
 |                                                Copyright © 2011  |
 |                                            basisforex@gmail.com  |
 +------------------------------------------------------------------*/
#property  copyright "Copyright © 2011"
#property  link      "basisforex@gmail.com"
//----------------------------------
#property  indicator_chart_window
#property  indicator_buffers 2
#property  indicator_color1  Blue
#property  indicator_color2  Yellow
//+------------------------------------------------------------------+
extern int       nAppliedPrice = 0;// PRICE_CLOSE=0; PRICE_OPEN=1; PRICE_HIGH=2; PRICE_LOW=3; PRICE_MEDIAN=4; PRICE_TYPICAL=5; PRICE_WEIGHTED=6;
extern int       maPeriod      = 55;
extern int       maMethod      = 0;// MODE_SMA=0; MODE_EMA=1; MODE_SMMA=2; MODE_LWMA=3; 
//----
double           BBPBuffer[];
double           TempBuffer[];
//+------------------------------------------------------------------+
int init()
 {  
   SetIndexBuffer(0, BBPBuffer);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(1, TempBuffer);
   SetIndexStyle(1, DRAW_LINE, STYLE_DOT);
   return(0);
 }
//+------------------------------------------------------------------+
int start()
 {
   int    i, j, nCountedBars; 
   nCountedBars = IndicatorCounted();
   i = Bars - nCountedBars;  
   //----
   while(i >= 0)
    {
      BBPBuffer[i] = (AppliedPrice(nAppliedPrice, i + 0) + AppliedPrice(nAppliedPrice, i + 1) + AppliedPrice(nAppliedPrice, i + 1)
                    + AppliedPrice(nAppliedPrice, i + 2) + AppliedPrice(nAppliedPrice, i + 3) + AppliedPrice(nAppliedPrice, i + 5)
                    + AppliedPrice(nAppliedPrice, i + 8) + AppliedPrice(nAppliedPrice, i + 13) + AppliedPrice(nAppliedPrice, i + 21)
                    + AppliedPrice(nAppliedPrice, i + 34) + AppliedPrice(nAppliedPrice, i + 55)) / 11;
      i--;
    } 
   i = Bars - nCountedBars;
   while(i >= 0)
    { 
      TempBuffer[i] = iMAOnArray(BBPBuffer, 0, maPeriod, 0, maMethod, i);
      i--;
    }  
   //---- 
 }   
//+------------------------------------------------------------------+
double AppliedPrice(int nAppliedPrice, int nIndex)
 {
   double aPrice;
   switch(nAppliedPrice)
    {
      case 0:  aPrice = Close[nIndex];                                        break;
      case 1:  aPrice = Open[nIndex];                                         break;
      case 2:  aPrice = High[nIndex];                                         break;
      case 3:  aPrice = Low[nIndex];                                          break;
      case 4:  aPrice = (High[nIndex]+Low[nIndex]) / 2.0;                     break;
      case 5:  aPrice = (High[nIndex]+Low[nIndex] + Close[nIndex]) / 3.0;     break;
      case 6:  aPrice = (High[nIndex]+Low[nIndex] + 2 * Close[nIndex]) / 4.0; break;
      default: aPrice = 0.0;
    }
   return(aPrice);
 }
//+------------------------------------------------------------------+

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