//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2012, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ /* * The operation of the indicator requires * SmoothAlgorithms.mqh file * in the directory: MetaTrader\\MQL5\Include * * ColorJFatlSpeed.mq5 * should be placed in the directory: MetaTrader\\MQL5\Indicators */ //+------------------------------------------------------------------+ //| JFatlSpeed_HTF.mq5 | //| Copyright © 2010, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //---- indicator version number #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //---- number of indicator buffers 4 #property indicator_buffers 4 //---- only four plots are used #property indicator_plots 4 //+----------------------------------------------+ //| Declaring constants | //+----------------------------------------------+ #define RESET 0 // The constant for returning the indicator recalculation command to the terminal #define INDICATOR_NAME "JFatl Speed" // The constant for the indicator name //+----------------------------------------------+ //| Parameters of drawing the bearish indicator | //+----------------------------------------------+ //---- drawing the indicator 1 as a symbol #property indicator_type1 DRAW_ARROW //---- red color is used as the color of the bearish indicator line #property indicator_color1 Red //---- width of the indicator 1 line is equal to 4 #property indicator_width1 4 //---- displaying the bullish label of the indicator #property indicator_label1 INDICATOR_NAME" Sell Max" //+----------------------------------------------+ //| Bullish indicator drawing parameters | //+----------------------------------------------+ //---- drawing the indicator 2 as a line #property indicator_type2 DRAW_ARROW //---- green color is used as the color of the bullish line of the indicator #property indicator_color2 Lime //---- width of the indicator 2 line is equal to 4 #property indicator_width2 4 //---- displaying the bearish label of the indicator #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 as the color of the bearish indicator line #property indicator_color3 Magenta //---- the width of the indicator 3 line is 4 #property indicator_width3 4 //---- displaying the bullish label of the indicator #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 line of the indicator #property indicator_color4 Yellow //---- width of the indicator 4 line is equal to 4 #property indicator_width4 4 //---- displaying the bearish label of the indicator #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_SIMPL_, //PRICE_SIMPL_ PRICE_QUARTER_, //PRICE_QUARTER_ PRICE_TRENDFOLLOW0_, //PRICE_TRENDFOLLOW0_ PRICE_TRENDFOLLOW1_ //PRICE_TRENDFOLLOW1_ }; //+-------------------------------------+ //| INDICATOR INPUT PARAMETERS | //+-------------------------------------+ input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4;//Chart period input uint LableShift=100;//Labels vertical shift input uint AlertCount=0;//Number of alerts input uint SignalBar=1;//Signal bar index, 0 is a current bar //+-------------------------------------+ //| INDICATOR INPUT PARAMETERS | //+-------------------------------------+ input int Length_=8; // JMA period of Fatl smoothing input int Phase_=100; // JMA parameter of Fatl smoothing, //varying within the range -100 ... +100, //impacts the transitional process quality; input int MomPeriod=1;//Momentum indicator period for rate measuring input int Smooth=2; // Depth of the JMA smoothing of the indicator input int SmPhase=100; // Parameter of the JMA smoothing of the indicator //varying within the range -100 ... +100, //impacts the transitional process quality; input Applied_price_ IPC=PRICE_CLOSE_;//price constant /* , used for the indicator calculation ( 1-CLOSE, 2-OPEN, 3-HIGH, 4-LOW, 5-MEDIAN, 6-TYPICAL, 7-WEIGHTED, 8-SIMPLE, 9-QUARTER, 10-TRENDFOLLOW, 11-0.5 * TRENDFOLLOW.) */ //input int FATLShift=0; // Horizontal shift of the indicator in bars //+-------------------------------------+ //---- declaration of dynamic arrays that will further // 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 strings string Symbol_,Word; //---- Declaration of integer variables of data starting point int min_rates_total; //---- Declaration of integer variables for the indicator handles int JFAccel_Handle; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int 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 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 in timeseries ArraySetAsSeries(time,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); //---- main cycle of calculation of the indicator for(bar=limit; bar>=0 && !IsStopped(); bar--) { //---- zero out the contents of the indicator buffers for the calculation BuyMaxBuffer[bar]=0.0; SellMaxBuffer[bar]=0.0; BuyMinBuffer[bar]=0.0; SellMinBuffer[bar]=0.0; //---- copy newly appeared data to 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