//+------------------------------------------------------------------+ //| Gator_HTF.mq5 | //| Copyright © 2011, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //---- indicator version number #property version "1.00" //---- drawing indicator in a separate window #property indicator_separate_window //---- number of indicator buffers 4 #property indicator_buffers 4 //---- only two plots are used #property indicator_plots 2 //+-----------------------------------+ //| Indicator 1 drawing parameters | //+-----------------------------------+ //---- drawing the indicator as a four-color histogram #property indicator_type1 DRAW_COLOR_HISTOGRAM //---- the following colors are used in the four color histogram #property indicator_color1 Green,Red //---- Indicator line is a solid one #property indicator_style1 STYLE_SOLID //---- indicator line width is equal to 5 #property indicator_width1 5 //---- displaying the indicator label #property indicator_label1 "Gator Upper HTF" //+-----------------------------------+ //| Indicator 2 drawing parameters | //+-----------------------------------+ //---- drawing the indicator as a four-color histogram #property indicator_type2 DRAW_COLOR_HISTOGRAM //---- the following colors are used in the four color histogram #property indicator_color2 Green,Red //---- Indicator line is a solid one #property indicator_style2 STYLE_SOLID //---- indicator line width is equal to 5 #property indicator_width2 5 //---- displaying the indicator label #property indicator_label2 "Gator Lower HTF" //+-----------------------------------+ //| Declaration of constants | //+-----------------------------------+ #define RESET 0 // the constant for getting the command for the indicator recalculation back to the terminal //+-----------------------------------+ //| Input parameters of the indicator| //+-----------------------------------+ input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; // Chart period input int JawsPeriod=13; // Jaws period input int JawsShift=8; // Jaws shift input int TeethPeriod=8; // Teeth period input int TeethShift=5; // Teeth shift input int LipsPeriod=5; // Lips period input int LipsShift=3; // Lips shift input ENUM_MA_METHOD MAMethod=MODE_SMMA; // Moving average method input ENUM_APPLIED_PRICE AppliedPrice=PRICE_MEDIAN; // Applied price input bool ReDraw=true; // Repeat display of information in the empty bars //+-----------------------------------+ //---- declaration of a variable for storing the indicator initialization result bool Init; double perratio; //---- declaration of the integer variables for the start of data calculation int min_rates_total; //---- declaration of integer variables for the indicators handles int Gator_Handle; //---- declaration of dynamic arrays that further //---- will be used as indicator buffers double UpperBuffer[],ColorUpBuffer[],LowerBuffer[],ColorLoBuffer[]; //+------------------------------------------------------------------+ //| Getting string timeframe | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) { //---- return(StringSubstr(EnumToString(timeframe),7,-1)); //---- } //+------------------------------------------------------------------+ //| Gator indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //---- initialization of variables perratio=PeriodSeconds(TimeFrame)/PeriodSeconds(PERIOD_CURRENT); min_rates_total=int(perratio*(MathMax(MathMax(JawsPeriod,TeethPeriod),LipsPeriod)+3)); Init=true; //---- checking correctness of the chart periods if(TimeFramerates_total || prev_calculated<=0)// checking for the first start of calculation of an indicator { limit=rates_total-min_rates_total-1; // starting index for calculation of all bars LastCountBar=rates_total; } else limit=int(LastCountBar)+rates_total-prev_calculated; // starting index for calculation of new bars //---- indexing elements in arrays as timeseries ArraySetAsSeries(time,true); //---- Main cycle of calculation of the indicator for(bar=limit; bar>=0 && !IsStopped(); bar--) { //---- zero out the contents of the indicator buffers for calculation UpperBuffer[bar]=EMPTY_VALUE; LowerBuffer[bar]=EMPTY_VALUE; ColorUpBuffer[bar]=-1; ColorLoBuffer[bar]=-1; //--- copy newly appeared data in the array if(CopyTime(Symbol(),TimeFrame,time[bar],1,GatorTime)<=0) return(RESET); if(time[bar]>=GatorTime[0] && time[bar+1]TeethPeriod>LipsPeriod; | //| 2.JawsShift>TeethShift>LipsShift; | //| 3.JawsPeriod>JawsShift; | //| 4.TeethPeriod>TeethShift; | //| 5.LipsPeriod>LipsShift. | //+------------------------------------------------------------------+ bool CheckForInput() { //--- 1 if(JawsPeriod<=TeethPeriod || TeethPeriod<=LipsPeriod) return(false); //--- 2 if(JawsShift<=TeethShift || TeethShift<=LipsShift) return(false); //--- 3 if(JawsPeriod<=JawsShift) return(false); //--- 4 if(TeethPeriod<=TeethShift) return(false); //--- 5 if(LipsPeriod<=LipsShift) return(false); //--- all right return(true); } //+------------------------------------------------------------------+