//+------------------------------------------------------------------+ //| UltraFatl_HTF.mq5 | //| Copyright © 2011, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ //| Place the SmoothAlgorithms.mqh file | //| to the directory: terminal_data_folder\MQL5\Include | //| the UltraFatl.mq5 file | //| to the directory: MetaTrader\\MQL5\Indicators | //+------------------------------------------------------------------+ #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 3 #property indicator_buffers 3 //--- only one plot is used #property indicator_plots 2 //+-----------------------------------+ //| Indicator drawing parameters | //+-----------------------------------+ //--- drawing the indicator as a histogram 2 #property indicator_type1 DRAW_COLOR_HISTOGRAM2 //--- colors of the four-color histogram are as follows #property indicator_color1 clrGray,clrMagenta,clrHotPink,clrRed,clrBrown,clrLimeGreen,clrTeal,clrLime,clrPaleGreen //--- 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 "UltraFatl HTF" //+-----------------------------------+ //| Declaration of constants | //+-----------------------------------+ #define RESET 0 // The constant for returning the indicator recalculation command to the terminal //+-----------------------------------+ //| Averaging classes description | //+-----------------------------------+ #include //+-----------------------------------+ //| Declaration of enumerations | //+-----------------------------------+ enum Applied_price_ //Type od constant { PRICE_CLOSE_ = 1, //Close PRICE_OPEN_, //Open PRICE_HIGH_, //High PRICE_LOW_, //Low PRICE_MEDIAN_, //Median Price (HL/2) PRICE_TYPICAL_, //Typical Price (HLC/3) PRICE_WEIGHTED_, //Weighted Close (HLCC/4) PRICE_SIMPL_, //Simpl Price (OC/2) PRICE_QUARTER_, //Quarted Price (HLOC/4) PRICE_TRENDFOLLOW0_, //TrendFollow_1 Price PRICE_TRENDFOLLOW1_ //TrendFollow_2 Price }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ /*enum Smooth_Method - enumeration is declared in SmoothAlgorithms.mqh { MODE_SMA_, //SMA MODE_EMA_, //EMA MODE_SMMA_, //SMMA MODE_LWMA_, //LWMA MODE_JJMA, //JJMA MODE_JurX, //JurX MODE_ParMA, //ParMA MODE_T3, //T3 MODE_VIDYA, //VIDYA MODE_AMA, //AMA }; */ //+-----------------------------------+ //| enumeration declaration | //+-----------------------------------+ enum WIDTH { Width_1=1, // 1 Width_2, // 2 Width_3, // 3 Width_4, // 4 Width_5 // 5 }; //+-----------------------------------+ //| enumeration declaration | //+-----------------------------------+ enum STYLE { SOLID_, // Solid line DASH_, // Dashed line DOT_, // Dotted line DASHDOT_, // Dot-dash line DASHDOTDOT_ // Dot-dash line with double dots }; //+-----------------------------------+ //| Indicator input parameters | //+-----------------------------------+ input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; // Chart period input ENUM_APPLIED_PRICE Applied_price=PRICE_CLOSE; // Applied price //--- input Smooth_Method W_Method=MODE_JJMA; // Smoothing method input int StartLength=3; // Initial smoothing period input int WPhase=100; // Smoothing parameter //--- input uint Step=5; // Period change step input uint StepsTotal=10; // Number of period changes //--- input Smooth_Method SmoothMethod=MODE_JJMA; // Smoothing method input int SmoothLength=3; // Smoothing depth input int SmoothPhase=100; // Smoothing parameter input Applied_price_ IPC=PRICE_CLOSE; // Price constant //--- input uint UpLevel=80; // Overbought level, % input uint DnLevel=20; // Oversold level, % input color UpLevelsColor=clrBlue; // Overbought level color input color DnLevelsColor=clrBlue; // Oversold level color input STYLE Levelstyle=DASH_; // Levels style input WIDTH LevelsWidth=Width_1; // Levels width input bool ReDraw=true; // Repeat of information show on the empty bars //+-----------------------------------+ //--- Declaration of a variable for storing the indicator initialization result bool Init; //--- declaration of the variables array for storing UltraFatl indicator signal lines periods int period[]; //--- declaration of integer variables of data starting point int min_rates_total; //--- declaration of integer variables for the indicator handles int UltraFatl_Handle; //--- double dUpLevel,dDnLevel; //--- declaration of dynamic arrays that will further be // used as indicator buffers double UpBuffer[],DnBuffer[],ColorBuffer[]; //+------------------------------------------------------------------+ //| Getting string timeframe | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) { //--- return(StringSubstr(EnumToString(timeframe),7,-1)); //--- } //+------------------------------------------------------------------+ //| UltraFatl indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- Initialization of variables of the start of data calculation min_rates_total=3; 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 timeseries ArraySetAsSeries(time,true); //--- main calculation loop of the indicator for(bar=limit; bar>=0 && !IsStopped(); bar--) { //--- zero out the contents of the indicator buffers for the calculation UpBuffer[bar]=EMPTY_VALUE; DnBuffer[bar]=EMPTY_VALUE; ColorBuffer[bar]=0; //--- copy newly appeared data in the array if(CopyTime(Symbol(),TimeFrame,time[bar],1,UltraFatlTime)<=0) return(RESET); if(time[bar]>=UltraFatlTime[0] && time[bar+1]