//+----------------------------------------------------------------------------------+ //| Din_fibo_Nex.mq5 | //| Copyright © 2006, unknown author, get from kaizer, conversed by Rosh | //|link to kaizer: http://forum.alpari-idc.ru/profile.php?mode=viewprofile&u=4196161 | //+----------------------------------------------------------------------------------+ #property copyright "Copyright © 2006, unknown author, get from kaizer, conversed by Rosh" #property link "http://forum.alpari-idc.ru/profile.php?mode=viewprofile&u=4196161" #property description "Trailing stop line indicator" //--- Indicator version #property version "1.00" //--- drawing the indicator in the main window #property indicator_chart_window //--- number of indicator buffers 3 #property indicator_buffers 3 //--- two plots are used #property indicator_plots 2 //+----------------------------------------------+ //| declaring constants | //+----------------------------------------------+ #define RESET 0 // A constant for returning the indicator recalculation command to the terminal //+----------------------------------------------+ //| Indicator 1 drawing parameters | //+----------------------------------------------+ //--- drawing indicator 1 as a line #property indicator_type1 DRAW_LINE //--- the color of the indicator #property indicator_color1 clrTeal //--- indicator 1 line width is equal to 2 #property indicator_width1 2 //--- displaying the indicator label #property indicator_label1 "Din_fibo_Nex MaH" //+----------------------------------------------+ //| Indicator 2 drawing parameters | //+----------------------------------------------+ //--- drawing indicator 2 as a line #property indicator_type2 DRAW_LINE //--- the color of the indicator #property indicator_color2 clrMaroon //--- indicator 2 line width is equal to 2 #property indicator_width2 2 //--- displaying the indicator label #property indicator_label2 "Din_fibo_Nex MaL" //+-----------------------------------+ //| Indicator input parameters | //+-----------------------------------+ input uint Fibo_Channel_Period=3; input double Ratio=0.786; //+-----------------------------------+ //--- declaration of dynamic arrays that //--- will be used as indicator buffers double ExtLineBuffer1[],ExtLineBuffer2[],tvBuffer[]; //--- declaration of the integer variables for the start of data calculation int min_rates_total; //+------------------------------------------------------------------+ //| Check - range separator or not | //+------------------------------------------------------------------+ bool isDelimeter(int TimeFrame,int Rates_total,const datetime &Time[],int shift) { //--- bool result=false; MqlDateTime tm; TimeToStruct(Time[shift],tm); //--- switch(TimeFrame) { case PERIOD_M1:result=(tm.min==0); break; case PERIOD_M2:result=(tm.min==0); break; case PERIOD_M3:result=(tm.min==0); break; case PERIOD_M4:result=(tm.min==0); break; case PERIOD_M5:result=(tm.min==0); break; case PERIOD_M6:result=(tm.min==0); break; case PERIOD_M10:result=(tm.min==0); break; case PERIOD_M12:result=(tm.min==0); break; case PERIOD_M15:result=(tm.min==0); break; case PERIOD_M20:result=(tm.min==0); break; case PERIOD_M30:result=(tm.min==0) && (MathMod(tm.hour,4.0)==0); break; case PERIOD_H1:result=(tm.min==0) && (MathMod(tm.hour,4.0)==0); break; case PERIOD_H2:result=(tm.min==0) && (MathMod(tm.hour,4.0)==0); break; case PERIOD_H3:result=(tm.min==0) && (tm.hour==0); break; case PERIOD_H4:result=(tm.min==0) && (tm.hour==0); break; case PERIOD_H6:result=(tm.min==0) && (tm.hour==0); break; case PERIOD_H8:result=(tm.min==0) && (tm.hour==0); break; case PERIOD_H12:result=(tm.min==0) && (tm.hour==0); break; case PERIOD_D1:result=(tm.day_of_week==MONDAY) && (tm.hour==0); break; case PERIOD_W1: { MqlDateTime tm1; TimeToStruct(Time[MathMin(Rates_total-1,shift+1)],tm1); result=(tm.day==1) || (tm.day==2 && tm1.day!=1) || (tm.day==3 && tm1.day!=2); break; } default: Print("Invalid timeframe!!!"); } //--- return(result); } //+------------------------------------------------------------------+ //| Set MaH and MaL at the range border | //+------------------------------------------------------------------+ void SetHnL(int Rates_total,const double &Low[],const double &High[],const double &Close[],int shift) { //--- int i=shift+1; int counterPeriod=0; int first=0; while(counterPeriodCurBar; m_cnt--) { ExtLineBuffer1[m_cnt]=ExtLineBuffer1[m_cnt+1]-deltaH; ExtLineBuffer2[m_cnt]=ExtLineBuffer2[m_cnt+1]-deltaL; } //--- for(m_cnt=DelimeterBar-1; m_cnt>CurBar; m_cnt--) { ExtLineBuffer1[m_cnt]=NormalizeDouble(ExtLineBuffer1[m_cnt],_Digits); ExtLineBuffer2[m_cnt]=NormalizeDouble(ExtLineBuffer2[m_cnt],_Digits); } //--- return; } //+------------------------------------------------------------------+ //| Set MaH and MaL on the right edge | //+------------------------------------------------------------------+ void SetValuesNullBar(int Rates_total,const double &Low[],const double &High[],const double &Close[],int shift) { //--- int i=shift; while(!tvBuffer[i]) i++; for(int j=i-1; j>shift; j--) { ExtLineBuffer1[j]=0.0; ExtLineBuffer2[j]=0.0; } //--- int first=0; i=shift; int counterPeriod=0; while(counterPeriodrates_total || prev_calculated<=0)// Checking for the first start of the indicator calculation { //--- find the first and second separator and set limit bar=rates_total-1; while(!isDelimeter(Period(),rates_total,time,bar)) bar--; int first=bar; bar--; int counterPeriod=0; while(counterPeriod=0 && !IsStopped(); bar--) { tvBuffer[bar]=0.0; if(isDelimeter(Period(),rates_total,time,bar)) SetHnL(rates_total,low,high,close,bar); if(!bar) SetValuesNullBar(rates_total,low,high,close,bar); } //--- return(rates_total); } //+------------------------------------------------------------------+