//+------------------------------------------------------------------------+ //| JFatlAcceleration_HTF.mq5 | //| Copyright © 2010, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------------+ //| Place the SmoothAlgorithms.mqh file | //| in the directory: terminal_data_folder\MQL5\Include | //| and also place ColorJFatlAcceleration.mq5 file in the directory: | //| terminal_data_folder\MQL5\Indicators | //+------------------------------------------------------------------------+ #property copyright "Copyright © 2010, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //---- indicator version #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //---- number of indicator buffers 4 #property indicator_buffers 4 //---- four plots are used in total #property indicator_plots 4 //+----------------------------------------------+ //| Declaration of constants | //+----------------------------------------------+ #define RESET 0 // The constant for getting the command for the indicator recalculation back to the terminal #define INDICATOR_NAME "JFatl Acceleration" // The constant for the indicator name //+----------------------------------------------+ //| Bearish indicator drawing parameters | //+----------------------------------------------+ //---- drawing the indicator 1 as a symbol #property indicator_type1 DRAW_ARROW //---- red color is used for the indicator #property indicator_color1 Red //---- indicator 1 line width is equal to 4 #property indicator_width1 4 //---- displaying the indicator label #property indicator_label1 INDICATOR_NAME" Sell Max" //+----------------------------------------------+ //| Bullish indicator drawing parameters | //+----------------------------------------------+ //---- drawing the indicator 2 as a line #property indicator_type2 DRAW_ARROW //---- lime color is used for the indicator #property indicator_color2 Lime //---- indicator 2 line width is equal to 4 #property indicator_width2 4 //---- displaying the indicator label #property indicator_label2 INDICATOR_NAME" Buy Max" //+----------------------------------------------+ //| Bearish indicator drawing parameters | //+----------------------------------------------+ //---- drawing the indicator 3 as a symbol #property indicator_type3 DRAW_ARROW //---- magenta color is used for the indicator #property indicator_color3 Magenta //---- the indicator 3 line width is equal to 4 #property indicator_width3 4 //---- displaying the indicator label #property indicator_label3 INDICATOR_NAME" Sell Min" //+----------------------------------------------+ //| Bullish indicator drawing parameters | //+----------------------------------------------+ //---- drawing the indicator 4 as a symbol #property indicator_type4 DRAW_ARROW //---- yellow color is used as the color of the bullish indicator line #property indicator_color4 Yellow //---- the indicator 4 line width is equal to 4 #property indicator_width4 4 //---- displaying the indicator label #property indicator_label4 INDICATOR_NAME" Buy Min" //+----------------------------------------------+ //| Declaration of enumerations | //+----------------------------------------------+ enum Smooth_Method { 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 }; enum Applied_price_ // Type of constant { PRICE_CLOSE_ = 1, // PRICE_CLOSE PRICE_OPEN_, // PRICE_OPEN PRICE_HIGH_, // PRICE_HIGH PRICE_LOW_, // PRICE_LOW PRICE_MEDIAN_, // PRICE_MEDIAN PRICE_TYPICAL_, // PRICE_TYPICAL PRICE_WEIGHTED_, // PRICE_WEIGHTED PRICE_SIMPLE, // PRICE_SIMPLE PRICE_QUARTER_, // PRICE_QUARTER_ PRICE_TRENDFOLLOW0_, // PRICE_TRENDFOLLOW0_ PRICE_TRENDFOLLOW1_ // PRICE_TRENDFOLLOW1_ }; //+-------------------------------------+ //| Indicator input parameters | //+-------------------------------------+ input uint LableShift=100; // Labels vertical shift input uint AlertCount=0; // Number of submitted alerts input uint SignalBar=1; // Signal bar index, 0 is a current bar input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; // Chart period input int Length_=8; // JMA period of Fatl smoothing input int Phase_=100; // JMA parameter of Fatl smoothing [-100...+100] input int SpeedPeriod=1; // Speed period input int AccelerationPeriod=1; // Acceleration period input int Smooth=2; // Indicator JMA smoothing depth input int SmPhase=100; // Indicator JMA smoothing parameter [-100...+100] input Applied_price_ IPC=PRICE_CLOSE_; // Applied price input int FATLShift=0; // Horizontal shift of the indicator in bars //---- declaration of dynamic arrays that //---- will be used as indicator buffers double BuyMaxBuffer[],SellMaxBuffer[]; double BuyMinBuffer[],SellMinBuffer[]; //---- declaration of a variable for storing the indicator initialization result bool Init; //---- declaration of a string variables string Symbol_,Word; //---- declaration of the integer variables for the start of data calculation int min_rates_total; //---- declaration of integer variables for the indicators handles int JFAccel_Handle; //+------------------------------------------------------------------+ //| 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 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); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); //---- main indicator calculation loop for(bar=limit; bar>=0 && !IsStopped(); bar--) { //---- zero out the contents of the indicator buffers for calculation BuyMaxBuffer[bar]=0.0; SellMaxBuffer[bar]=0.0; BuyMinBuffer[bar]=0.0; SellMinBuffer[bar]=0.0; //---- copy newly appeared data in the JFAccelTime[] array if(CopyTime(Symbol_,TimeFrame,time[bar],1,JFAccelTime)<=0) return(RESET); if(time[bar]>=JFAccelTime[0] && time[bar+1]JFAccel[1]) SellMaxBuffer[bar]=high[bar]+LableShift*_Point; else SellMinBuffer[bar]=high[bar]+LableShift*_Point; } else { if(JFAccel[0]>JFAccel[1]) BuyMinBuffer[bar]=low[bar]-LableShift*_Point; else BuyMaxBuffer[bar]=low[bar]-LableShift*_Point; } } } //---- alerts counters reset to zeros if(rates_total!=prev_calculated) { UpCount=0; DnCount=0; UpCount_=0; DnCount_=0; } //---- submission of an alert for buying if(UpCount