//+------------------------------------------------------------------+ //| i-IntradayFibonacci.mq5 | //| Copyright © 2007, Kim Igor V. aka KimIV | //| http://www.kimiv.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, Kim Igor V. aka KimIV" #property link "http://www.kimiv.ru" //---- indicator version number #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //---- number of indicator buffers 8 #property indicator_buffers 8 //---- 8 graphical plots are used in total #property indicator_plots 8 //+----------------------------------------------+ //| declaring constants | //+----------------------------------------------+ #define RESET 0 // The constant for returning the indicator recalculation command to the terminal #define INDICATOR_NAME "i-IntradayFibonacci" // The constant for the indicator name //+----------------------------------------------+ //| Indicator drawing parameters | //+----------------------------------------------+ //---- drawing the indicators as lines #property indicator_type1 DRAW_ARROW #property indicator_type2 DRAW_ARROW #property indicator_type3 DRAW_ARROW #property indicator_type4 DRAW_ARROW #property indicator_type5 DRAW_ARROW #property indicator_type6 DRAW_ARROW #property indicator_type7 DRAW_ARROW #property indicator_type8 DRAW_ARROW //---- the following colors are used as the indicator colors #property indicator_color1 clrBlue #property indicator_color2 clrLime #property indicator_color3 clrOrange #property indicator_color4 clrDeepPink #property indicator_color5 clrDeepPink #property indicator_color6 clrOrange #property indicator_color7 clrLime #property indicator_color8 clrBlue //---- width of the indicator lines is equal to 1 #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 #property indicator_width5 1 #property indicator_width6 1 #property indicator_width7 1 #property indicator_width8 1 //---- displaying the indicator label #property indicator_label1 INDICATOR_NAME+" +0.764" #property indicator_label2 INDICATOR_NAME+" +0.618" #property indicator_label3 INDICATOR_NAME+" +0.382" #property indicator_label4 INDICATOR_NAME+" +0.236" #property indicator_label1 INDICATOR_NAME+" -0.236" #property indicator_label2 INDICATOR_NAME+" -0.382" #property indicator_label3 INDICATOR_NAME+" -0.618" #property indicator_label4 INDICATOR_NAME+" -0.764" //+-------------------------------------+ //| INDICATOR INPUT PARAMETERS | //+-------------------------------------+ input ENUM_TIMEFRAMES TimeFrame=PERIOD_D1; // Chart period input int Shift=0; // horizontal shift of the indicator in bars input int PriceShift=0; // vertical shift of the indicator in points //+-------------------------------------+ //---- declaration of dynamic arrays that will further be // used as indicator buffers double IndBuffer1[],IndBuffer2[],IndBuffer3[],IndBuffer4[]; double IndBuffer5[],IndBuffer6[],IndBuffer7[],IndBuffer8[]; //---- Declaration of a variable for storing the indicator initialization result bool Init; //---- Declaration of strings string Symbol_; //---- Declaration of integer variables of data starting point int min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void IndInit(int Number,double& Arrow[],int DRAW_BEGIN_,double EMPTY_VALUE_) { //---- set dynamic array as an indicator buffer SetIndexBuffer(Number,Arrow,INDICATOR_DATA); //---- shifting the starting point of the indicator drawing PlotIndexSetInteger(Number,PLOT_DRAW_BEGIN,DRAW_BEGIN_); //---- setting values of the indicator that won't be visible on a chart PlotIndexSetDouble(Number,PLOT_EMPTY_VALUE,EMPTY_VALUE_); //---- indexing elements in the buffer as in timeseries ArraySetAsSeries(Arrow,true); //---- } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { Init=true; //---- checking correctness of the chart periods if(TimeFramerates_total || prev_calculated<=0)// checking for the first start of the indicator calculation { limit=rates_total-min_rates_total-1; // starting index for the calculation of all bars LastCountBar=rates_total; } else limit=int(LastCountBar)+rates_total-prev_calculated; // starting index for the calculation of new bars //---- indexing elements in arrays as in timeseries ArraySetAsSeries(time,true); //---- main cycle of calculation of the indicator for(bar=limit; bar>=0 && !IsStopped(); bar--) { //---- copy new data to the iTime array if(CopyTime(Symbol_,TimeFrame,time[bar],1,iTime)<=0) return(RESET); if(time[bar]>=iTime[0] && time[bar+1]