//+---------------------------------------------------------------------+ //| MultiJFatlSpeedx7Signal.mq5 | //| Copyright © 2014, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+---------------------------------------------------------------------+ //| Place the SmoothAlgorithms.mqh file | //| in the directory: terminal_data_folder\MQL5\Include | //+---------------------------------------------------------------------+ #property copyright "Copyright © 2014, Nikolay Kositsin" #property link "farria@mail.redcom.ru" #property description "" //--- indicator version #property version "1.60" //--- drawing the indicator in a separate window #property indicator_separate_window //--- fixed height of the indicator subwindow in pixels #property indicator_height 90 //--- lower and upper scale limit of a separate indicator window #property indicator_maximum +7.9 #property indicator_minimum +0.3 //+-----------------------------------+ //| Declaration of constants | //+-----------------------------------+ #define RESET 0 // A constant for returning the indicator recalculation command to the terminal #define INDTOTAL 7 // A constant for the number of displayed indicators #define INDICATOR_NAME "JFatlSpeed" // A constant for the indicator name //+-----------------------------------+ //---- number of indicator buffers #property indicator_buffers 28 // INDTOTAL*4 //--- total plots used #property indicator_plots 21 // INDTOTAL*3 //+-----------------------------------+ //| Indicator 1 drawing parameters | //+-----------------------------------+ //--- drawing indicator 1 as a line #property indicator_type1 DRAW_COLOR_LINE //--- the following colors are used for the indicator line #property indicator_color1 clrGray,clrMagenta,clrTeal //--- the indicator line is dashed #property indicator_style1 STYLE_SOLID //--- indicator line width is 3 #property indicator_width1 3 //--- displaying the indicator label ////#property indicator_label1 "Signal line 1" //+-----------------------------------+ //| Indicator 1 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 1 as a label #property indicator_type2 DRAW_ARROW //--- the color used as a label color #property indicator_color2 clrLimeGreen //--- indicator line width is 5 #property indicator_width2 5 //+-----------------------------------+ //| Indicator 1 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 1 as a label #property indicator_type3 DRAW_ARROW //--- the color used as a label color #property indicator_color3 clrRed //--- indicator line width is 5 #property indicator_width3 5 //+-----------------------------------+ //| Indicator 2 drawing parameters | //+-----------------------------------+ //--- drawing indicator 2 as a line #property indicator_type4 DRAW_COLOR_LINE //--- the following colors are used for the indicator line #property indicator_color4 clrGray,clrMagenta,clrTeal //--- the indicator line is dashed #property indicator_style4 STYLE_SOLID //--- indicator line width is 3 #property indicator_width4 3 //+-----------------------------------+ //| Indicator 2 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 2 as a label #property indicator_type5 DRAW_ARROW //--- the color used as a label color #property indicator_color5 clrLimeGreen //--- indicator line width is 5 #property indicator_width5 5 //+-----------------------------------+ //| Indicator 2 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 2 as a label #property indicator_type6 DRAW_ARROW //--- the color used as a label color #property indicator_color6 clrRed //--- indicator line width is 5 #property indicator_width6 5 //+-----------------------------------+ //| Indicator 3 drawing parameters | //+-----------------------------------+ //--- drawing indicator 3 as a line #property indicator_type7 DRAW_COLOR_LINE //--- the following colors are used for the indicator line #property indicator_color7 clrGray,clrMagenta,clrTeal //--- the indicator line is dashed #property indicator_style7 STYLE_SOLID //--- indicator line width is 3 #property indicator_width7 3 //+-----------------------------------+ //| Indicator 3 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 3 as a label #property indicator_type8 DRAW_ARROW //--- the color used as a label color #property indicator_color8 clrLimeGreen //--- indicator line width is 5 #property indicator_width8 5 //+-----------------------------------+ //| Indicator 3 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 3 as a label #property indicator_type9 DRAW_ARROW //--- the color used as a label color #property indicator_color9 clrRed //--- indicator line width is 5 #property indicator_width9 5 //+-----------------------------------+ //| Indicator 4 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 4 as a line #property indicator_type10 DRAW_COLOR_LINE //--- the following colors are used for the indicator line #property indicator_color10 clrGray,clrMagenta,clrTeal //--- the indicator line is dashed #property indicator_style10 STYLE_SOLID //--- indicator line width is 3 #property indicator_width10 3 //+-----------------------------------+ //| Indicator 4 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 4 as a label #property indicator_type11 DRAW_ARROW //--- the color used as a label color #property indicator_color11 clrLimeGreen //--- indicator line width is 5 #property indicator_width11 5 //+-----------------------------------+ //| Indicator 4 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 4 as a label #property indicator_type12 DRAW_ARROW //--- the color used as a label color #property indicator_color12 clrRed //--- indicator line width is 5 #property indicator_width12 5 //+-----------------------------------+ //| Indicator 5 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 5 as a line #property indicator_type13 DRAW_COLOR_LINE //--- the following colors are used for the indicator line #property indicator_color13 clrGray,clrMagenta,clrTeal //--- the indicator line is dashed #property indicator_style13 STYLE_SOLID //--- indicator line width is 3 #property indicator_width13 3 //+-----------------------------------+ //| Indicator 5 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 5 as a label #property indicator_type14 DRAW_ARROW //--- the color used as a label color #property indicator_color14 clrLimeGreen //--- indicator line width is 5 #property indicator_width14 5 //+-----------------------------------+ //| Indicator 5 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 5 as a label #property indicator_type15 DRAW_ARROW //--- the color used as a label color #property indicator_color15 clrRed //--- indicator line width is 5 #property indicator_width15 5 //+-----------------------------------+ //| Indicator 6 drawing parameters | //+-----------------------------------+ //--- Drawing indicator 6 as line #property indicator_type16 DRAW_COLOR_LINE //--- the following colors are used for the indicator line #property indicator_color16 clrGray,clrMagenta,clrTeal //--- the indicator line is dashed #property indicator_style16 STYLE_SOLID //--- indicator line width is 3 #property indicator_width16 3 //+-----------------------------------+ //| Indicator 6 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 6 as a label #property indicator_type17 DRAW_ARROW //--- the color used as a label color #property indicator_color17 clrLimeGreen //--- indicator line width is 5 #property indicator_width17 5 //+-----------------------------------+ //| Indicator 6 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 6 as a label #property indicator_type18 DRAW_ARROW //--- the color used as a label color #property indicator_color18 clrRed //--- indicator line width is 5 #property indicator_width18 5 //+-----------------------------------+ //| Indicator 7 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 7 as a line #property indicator_type19 DRAW_COLOR_LINE //--- the following colors are used for the indicator line #property indicator_color19 clrGray,clrMagenta,clrTeal //--- the indicator line is dashed #property indicator_style19 STYLE_SOLID //--- indicator line width is 1 #property indicator_width19 1 //+-----------------------------------+ //| Indicator 7 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 7 as a label #property indicator_type20 DRAW_ARROW //--- the color used as a label color #property indicator_color20 clrLimeGreen //--- indicator line width is 2 #property indicator_width20 2 //+-----------------------------------+ //| Indicator 7 drawing parameters | //+-----------------------------------+ //--- drawing the indicator 7 as a label #property indicator_type21 DRAW_ARROW //--- the color used as a label color #property indicator_color21 clrRed //--- indicator line width is 2 #property indicator_width21 2 //+-----------------------------------+ //| Declaration of enumerations | //+-----------------------------------+ enum Applied_price_ //Type of 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_SIMPLE_, //Simple Price (OC/2) PRICE_QUARTER_, //Quarted Price (HLOC/4) PRICE_TRENDFOLLOW0_, //TrendFollow_1 Price PRICE_TRENDFOLLOW1_, //TrendFollow_2 Price PRICE_DEMARK_ //Demark Price }; //+-----------------------------------+ //| Indicator input parameters | //+-----------------------------------+ input ENUM_TIMEFRAMES TimeFrame0=PERIOD_D1; //1 Chart period input ENUM_TIMEFRAMES TimeFrame1=PERIOD_H12; //2 Chart period input ENUM_TIMEFRAMES TimeFrame2=PERIOD_H8; //3 Chart period input ENUM_TIMEFRAMES TimeFrame3=PERIOD_H6; //4 Chart period input ENUM_TIMEFRAMES TimeFrame4=PERIOD_H4; //5 Chart period input ENUM_TIMEFRAMES TimeFrame5=PERIOD_H2; //6 Chart period input ENUM_TIMEFRAMES TimeFrame6=PERIOD_M30; //7 Chart period //--- input int JLength=8; // JMA period of Fatl smoothing input int JPhase=100; // JMA period of Fatl smoothing [-100..+100] input int MomPeriod=1; // Momentum indicator period for rate measuring input int Smooth=2; // Indicator JMA smoothing depth input int SmPhase=100; // Indicator JMA smoothing parameter [-100..+100] input Applied_price_ IPC=PRICE_CLOSE_; // Price constant //+-----------------------------------+ //--- declaration of integer variables of data starting point int min_rates_total; //+------------------------------------------------------------------+ //| Getting a timeframe as a line | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) {return(StringSubstr(EnumToString(timeframe),7,-1));} //+------------------------------------------------------------------+ //| Indicator buffer class | //+------------------------------------------------------------------+ class CIndBuffers { //--- public: double m_UpBuffer[]; double m_DnBuffer[]; double m_LineBuffer[]; double m_ColorLineBuffer[]; int m_Handle; ENUM_TIMEFRAMES m_TimeFrame; //--- }; //--- declaration of dynamic arrays that //--- will be used as indicator buffers CIndBuffers Ind[INDTOTAL]; //+------------------------------------------------------------------+ //| JFatlSpeed indicator initialization function | //+------------------------------------------------------------------+ bool IndInit(uint Number) { //--- checking correctness of the chart periods if(Ind[Number].m_TimeFrameRates_Total || Prev_Calculated<=0)// checking for the first start of the indicator calculation { LastCountBar[Number]=Rates_Total; limit_=Limit; } else limit_=int(LastCountBar[Number])+Limit; // starting index for the calculation of new bars //--- main calculation loop of the indicator for(int bar=int(limit_); bar>=0 && !IsStopped(); bar--) { //--- Zero out the contents of the indicator buffers for the calculation Ind[Number].m_UpBuffer[bar]=EMPTY_VALUE; Ind[Number].m_DnBuffer[bar]=EMPTY_VALUE; Ind[Number].m_LineBuffer[bar]=Number+1.0; Ind[Number].m_ColorLineBuffer[bar]=0; Time0=Time[bar]; //--- copy newly appeared data in the array if(CopyTime(Symbol(),Ind[Number].m_TimeFrame,Time0,1,Time_)<=0) return(RESET); if(Time0>=Time_[0] && Time[bar+1]JFatlSpeed[0]) { Ind[Number].m_UpBuffer[bar]=Number+1.0; Ind[Number].m_ColorLineBuffer[bar]=2; } if(JFatlSpeed[1]rates_total || prev_calculated<=0)// checking for the first start of calculation of an indicator limit=rates_total-min_rates_total-1; // starting index for the calculation of all bars else limit=rates_total-prev_calculated; // starting index for the calculation of new bars //--- apply timeseries indexing to array elements ArraySetAsSeries(time,true); //--- for(int count=0; count