Navigation:Home > Content >

lastweekfibo.mq4

Time: 2013-01-07 | Download file:lastweekfibo.mq4

//+------------------------------------------------------------------+
//|                                                LastWeekFibo.mq4  |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//--- input parameters
extern int startWeekDayOfWeek=1; //Start Week Day 1 For East 7 For West
input ENUM_TIMEFRAMES minTimeFrames= PERIOD_H1; // Min Time Frames
input ENUM_TIMEFRAMES maxTimeFrames= PERIOD_D1; // Max Time Frames
input color TimeRangeColor=clrRed; //Time Range Line Color
input color PriceRangeColor=clrRed; //Price Range Line Color
input color PriceMarkColor=clrBlue; //Price Mark Color
input color GoldenSectionColor=clrBlue; //Golden Section Color
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(Period()>=minTimeFrames && Period()<=maxTimeFrames && Period()=minTimeFrames && Period()<=maxTimeFrames && Period()LastWeekLowPriceIndex)
        {
         DrawFiboComplete("FibooLastWeek",Time[LastWeekHighPriceIndex],LastWeekHighPrice,Time[LastWeekLowPriceIndex],LastWeekLowPrice);
        }
      else
        {
         DrawFiboComplete("FibooLastWeek",Time[LastWeekLowPriceIndex],LastWeekLowPrice,Time[LastWeekHighPriceIndex],LastWeekHighPrice);
        }
      ObjectSetStyle("FibooLastWeek","Golden Section",GoldenSectionColor,STYLE_DOT,1);
      ObjectSetLevelStyle("FibooLastWeek","Golden Section",GoldenSectionColor,STYLE_SOLID,1);
     }
  }
//+------------------------------------------------------------------+
//| DrawHLine Function                                               |
//+------------------------------------------------------------------+
void DrawHLine(string hlineName,double price)
  {
   ObjectCreate(hlineName,OBJ_HLINE,0,NULL,price);
  }
//+------------------------------------------------------------------+
//| DrawVLine Function                                               |
//+------------------------------------------------------------------+
void DrawVLine(string vlineName,datetime time)
  {
   ObjectCreate(vlineName,OBJ_VLINE,0,time,NULL);
  }
//+------------------------------------------------------------------+
//|                DrawArrow Function                                |
//+------------------------------------------------------------------+
void DrawArrow(string arrowName,datetime time,double price,uint arrowCode)
  {
   ObjectCreate(arrowName,OBJ_ARROW,0,time,price);
   ObjectSet(arrowName,OBJPROP_ARROWCODE,arrowCode);
  }
//+------------------------------------------------------------------+
//| DrawFiboComplete Function From -100% To +100%                    | 
//+------------------------------------------------------------------+
void DrawFiboComplete(string fiboName,datetime firstTime,double firstPrice,datetime secondTime,double secondPrice)
  {
   ObjectCreate(fiboName,OBJ_FIBO,0,firstTime,firstPrice,secondTime,secondPrice);
//---
   ObjectSet(fiboName,OBJPROP_FIBOLEVELS,25);
//---
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+18,-1.000);ObjectSetFiboDescription(fiboName,+18,"-100.0%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+17,-0.764);ObjectSetFiboDescription(fiboName,+17,"-76.4%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+16,-0.618);ObjectSetFiboDescription(fiboName,+16,"-61.8%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+15,-0.50);ObjectSetFiboDescription(fiboName,+15,"-50.0%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+14,-0.382);ObjectSetFiboDescription(fiboName,+14,"-38.2%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+13,-0.236);ObjectSetFiboDescription(fiboName,+13,"-23.6%% = %$");
//---
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+0,0.000);ObjectSetFiboDescription(fiboName,0,"00.0%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+1,0.236);ObjectSetFiboDescription(fiboName,1,"23.6%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+2,0.382);ObjectSetFiboDescription(fiboName,2,"38.2%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+3,0.500);ObjectSetFiboDescription(fiboName,3,"50.0%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+4,0.618);ObjectSetFiboDescription(fiboName,4,"61.8%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+5,0.764);ObjectSetFiboDescription(fiboName,5,"76.4%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+6,1.000);ObjectSetFiboDescription(fiboName,6,"100.0%% = %$");
//---
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+7,1.236);ObjectSetFiboDescription(fiboName,7,"123.6%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+8,1.382);ObjectSetFiboDescription(fiboName,8,"138.2%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+9,1.50);ObjectSetFiboDescription(fiboName,9,"150.0%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+10,1.618);ObjectSetFiboDescription(fiboName,10,"161.8%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+11,1.764);ObjectSetFiboDescription(fiboName,11,"176.4%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+12,2.000);ObjectSetFiboDescription(fiboName,12,"200.0%% = %$");
   ObjectSet(fiboName,OBJPROP_RAY,true);
  }
//+------------------------------------------------------------------+
//| DrawFiboSimple Function From 0% To +100%                         | 
//+------------------------------------------------------------------+
void DrawFiboSimple(string fiboName,datetime firstTime,double firstPrice,datetime secondTime,double secondPrice)
  {
   ObjectCreate(fiboName,OBJ_FIBO,0,firstTime,firstPrice,secondTime,secondPrice);
   ObjectSet(fiboName,OBJPROP_FIBOLEVELS,20);
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+0,0.000);ObjectSetFiboDescription(fiboName,0,"00.0%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+1,0.236);ObjectSetFiboDescription(fiboName,1,"23.6%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+2,0.382);ObjectSetFiboDescription(fiboName,2,"38.2%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+3,0.500);ObjectSetFiboDescription(fiboName,3,"50.0%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+4,0.618);ObjectSetFiboDescription(fiboName,4,"61.8%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+5,0.764);ObjectSetFiboDescription(fiboName,5,"76.4%% = %$");
   ObjectSet(fiboName,OBJPROP_FIRSTLEVEL+6,1.000);ObjectSetFiboDescription(fiboName,6,"100.0%% = %$");
   ObjectSet(fiboName,OBJPROP_RAY,true);
  }
//+------------------------------------------------------------------+
//| ObjectSetStyle Function                                          |
//+------------------------------------------------------------------+
void ObjectSetStyle(string objectName,string devation,color _color,uint style,uint width)
  {
//ObjectSet(objectName,OBJPROP_DEVIATION,ObjectDescription(devation));
   ObjectSet(objectName,OBJPROP_COLOR,_color);
   ObjectSet(objectName,OBJPROP_STYLE,style);
   ObjectSet(objectName,OBJPROP_WIDTH,width);
  }
//+------------------------------------------------------------------+
//| ObjectSetLevelStyle Function                                     |
//+------------------------------------------------------------------+
void ObjectSetLevelStyle(string objectName,string devation,color _color,uint style,uint width)
  {
   ObjectSet(objectName,OBJPROP_LEVELCOLOR,_color);
   ObjectSet(objectName,OBJPROP_LEVELSTYLE,style);
   ObjectSet(objectName,OBJPROP_LEVELWIDTH,width);
  }
//+------------------------------------------------------------------+

Recommend