Navigation:Home > Content >

Fibo-PivotPoints.mq4

Time: 2012-09-13 | Download file:Fibo-PivotPoints.mq4

//+------------------------------------------------------------------+
//|                                                      Logging.mq4 |
//|                          Copyright © 2008, Empryean Software Ltd |
//|                                      http://finance.empryean.com |
//|                    Tinashe B Chipomho ([email protected])|
//|                                                                  |
//|  19 Feb 2008 1.1 Tinashe B Chipomho                              |
//|                  Initial version                                 |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Empryean Software Ltd"
#property link      "http://finance.empryean.com"
#property library

#include 
#include 
#include 

void GetCurrentFiboPivotPoints(double& prices[]){
  int e = 0;
  ArrayResize(prices,7);                                           
  e=GetLastError();
  if (e>0)
    Print("ArrayResize: "+ ErrorDescription(e));
  double rates[1][6],yesterday_close,yesterday_high,yesterday_low;
  ArrayCopyRates(rates, Symbol(), PERIOD_D1);
  e=GetLastError();
  if (e>0)
    Print("ArrayCopyRates: "+ ErrorDescription(e));
  
  if(DayOfWeek() == 1){
    if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,1)) == 5){
      yesterday_close = rates[1][4];
      yesterday_high = rates[1][3];
      yesterday_low = rates[1][2];
    }
    else{
      for(int d = 5;d>=0;d--){
        if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,d)) == 5){
          yesterday_close = rates[d][4];
          yesterday_high = rates[d][3];
          yesterday_low = rates[d][2];
        }
      }  
    }
  }
  else{
    yesterday_close = rates[1][4];
    yesterday_high = rates[1][3];
    yesterday_low = rates[1][2];
  }
  
  
  double R = yesterday_high - yesterday_low;//range
  double pivot = NormalizeDouble((yesterday_high + yesterday_low + yesterday_close)/3,Digits);// Standard Pivot
  
  pivot=NormalizeDouble(pivot,Digits);

  prices[FIBO_LEVEL_PIVOT] = NormalizeDouble(pivot,Digits);
  prices[FIBO_LEVEL_R3] = NormalizeDouble(pivot + (R * 1.000),Digits);
  prices[FIBO_LEVEL_R2] = NormalizeDouble(pivot + (R * 0.618),Digits);
  prices[FIBO_LEVEL_R1] = NormalizeDouble(pivot + (R * 0.382),Digits);
  prices[FIBO_LEVEL_S1] = NormalizeDouble(pivot - (R * 0.382),Digits);
  prices[FIBO_LEVEL_S2] = NormalizeDouble(pivot - (R * 0.618),Digits);
  prices[FIBO_LEVEL_S3] = NormalizeDouble(pivot - (R * 1.000),Digits);
  
  
}

Recommend