Ultra Trend MTF Indicator For MT5

Ultra Trend MTF Indicator For MT5

The Ultra Trend MTF Indicator For MT5 makes a multi timeframe trend analysis and shows the result as an oscillator in a subwindow. The indicator automatically calculates the trend values for the next 3 higher timeframes and aggregates the values into one single value.

FREE Ultra Trend MTF Indicator

Download the FREE Ultra Trend MTF Indicator for MT5.

To receive my email 100% sure: 
Put my email on your whitelist!


Partially Automated Trading Besides Your Day Job

Alerts In Real-Time When Divergences Occur

My Recommended MT4/MT5 Broker


Installing the Ultra Trend MTF Indicator For MT5

After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file Ultra trend mtf.mq5 into the folder MQL5\Indicators of your MT5 installation. After that please restart MT5 and then you will be able to see the indicator in the list of indicators.

Parameters of the Ultra Trend MTF Indicator For MT5

The Ultra Trend MTF Indicator For MT5 has 7 parameters to configure.

input enTimeFrames inpTimeFrame   = tf_cu; // Time frame
input int          inpUtrPeriod   = 3;     // Start period
input int          inpProgression = 5;     // Step
input int          inpInstances   = 30;    // Instances
input int          inpSmooth      = 5;     // Ultra trend smoothing period
input int          inpSmoothPhase = 100;   // Ultra trend smoothing phase
input bool         inpInterpolate = true;  // Interpolate in multi time frame mode?

Buffers of the Ultra Trend MTF Indicator For MT5

The Ultra Trend MTF Indicator For MT5 provides 7 buffers.


Main Parts Of The Code

int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
   if(Bars(_Symbol,_Period) lt rates_total) return(prev_calculated);
      double result[];
      if(BarsCalculated(_mtfHandle) lt 0)                     return(prev_calculated);
      if(!timeFrameCheck((ENUM_TIMEFRAMES)timeFrame,time)) return(prev_calculated);
      if(CopyBuffer(_mtfHandle,6,0,1,result)==-1)          return(prev_calculated);


      #define _mtfRatio PeriodSeconds((ENUM_TIMEFRAMES)timeFrame)/PeriodSeconds(_Period)
      int k,n,i=MathMin(MathMax(prev_calculated-1,0),MathMax(rates_total-(int)result[0]*_mtfRatio-1,0)),_prevMark=0,_seconds=PeriodSeconds(timeFrame);
      for(; i lt rates_total && !_StopFlag; i++)
         int _currMark = int(time[i]/_seconds);
         if (_currMark!=_prevMark)
            _prevMark = _currMark; 
            #define _mtfCopy(_buff,_buffNo) if(CopyBuffer(_mtfHandle,_buffNo,time[i],1,result)==-1) break; _buff[i]=result[0]
                    _mtfCopy(valp ,2);
                    _mtfCopy(valm ,4);
            fillu[i] = fillu[i-1];
            filld[i] = filld[i-1];
            valp[i]  = valp[i-1];
            valpc[i] = valpc[i-1];
            valm[i]  = valm[i-1];
            valmc[i] = valmc[i-1];


         if (!inpInterpolate)  continue; 
            int _nextMark = (i lt rates_total-1) ? int(time[i+1]/_seconds) : _prevMark+1; if (_nextMark == _prevMark) continue;
            for(n=1; (i-n) gt  0 && time[i-n]  gt = (_prevMark)*_seconds; n++) continue;
            for(k=1; (i-k) gt =0 && k lt n; k++)
               #define _mtfInterpolate(_buff) _buff[i-k]=_buff[i]+(_buff[i-n]-_buff[i])*k/n
   int endLength=inpUtrPeriod+inpProgression*inpInstances;
   int i=(int)MathMax(prev_calculated-1,0); for(; i lt rates_total && !_StopFlag; i++)
      double valueUp=0;
      double valueDn=0;

      for(int k=inpUtrPeriod,instance=2; k lt =endLength && i gt 0; k+=inpProgression,instance++)
         if(_iSmooth[instance].CalculateValue(close[i-1],k,inpSmoothPhase,i-1,rates_total) lt _iSmooth[instance].CalculateValue(close[i],k,inpSmoothPhase,i,rates_total))
         else valueDn++;
      valp[i]  = _iSmooth[0].CalculateValue(valueUp,inpSmooth,inpSmoothPhase,i,rates_total);
      valm[i]  = _iSmooth[1].CalculateValue(valueDn,inpSmooth,inpSmoothPhase,i,rates_total);
      valpc[i] = (valp[i] gt valm[i]) ? 1 : 2;
      valmc[i] = valpc[i];
      fillu[i] = valp[i];
      filld[i] = valm[i];
   return (i);
//| Custom functions                                                 |
string          _tfsStr[]={"1 minute","2 minutes","3 minutes","4 minutes","5 minutes","6 minutes","10 minutes","12 minutes","15 minutes","20 minutes","30 minutes","1 hour","2 hours","3 hours","4 hours","6 hours","8 hours","12 hours","daily","weekly","monthly"};
string timeFrameToString(int period)
   int i; for(i=0;i lt ArraySize(_tfsPer);i++) if(period==_tfsPer[i]) break;
ENUM_TIMEFRAMES timeFrameGet(int period)
   int _shift=(period lt 0?MathAbs(period):0);
   if(_shift gt 0 || period==tf_cu) period=_Period;
   int i; for(i=0;i lt ArraySize(_tfsPer);i++) if(period==_tfsPer[i]) break;

string getIndicatorName()
   string _path=MQL5InfoString(MQL5_PROGRAM_PATH);
   string _partsA[];
   ushort _partsS=StringGetCharacter("\",0);
   int _partsN = StringSplit(_path,_partsS,_partsA);
   string name = _partsA[_partsN-1]; for(int n=_partsN-2; n gt =0 && _toLower(_partsA[n])!="indicators"; n--) name = _partsA[n]+"\"+name;
string _toLower(string _toConvert) { StringToLower(_toConvert); return(_toConvert); }
bool timeFrameCheck(ENUM_TIMEFRAMES _timeFrame,const datetime &time[])
   static bool warned=false;
   if(time[0] lt SeriesInfoInteger(_Symbol,_timeFrame,SERIES_FIRSTDATE))
      datetime startTime,testTime[];
      if(startTime gt 0)                       { CopyTime(_Symbol,_timeFrame,time[0],1,testTime); SeriesInfoInteger(_Symbol,_timeFrame,SERIES_FIRSTDATE,startTime); }
      if(startTime lt =0 || startTime gt time[0]) { Comment(MQL5InfoString(MQL5_PROGRAM_NAME)+"
Missing data for "+timeFrameToString(_timeFrame)+" time frame
Re-trying on next tick"); warned=true; return(false); }
   if(warned) { Comment(""); warned=false; }


About Me

I'm Mike Semlitsch the owner of PerfectTrendSystem.com. My trading career started in 2007. Since 2013 I have helped thousands of traders to take their trading to the next level. Many of them are now constantly profitable traders. 

The following performance was achieved by me while trading live in front of hundreds of my clients:

Connect With Me:  

This FREE Indicator Can Transform
Your Trading!

FREE Indicator + Telegram Group

Request the Ultimate Double Top/Bottom Indicator which is used by 10,000+ traders.

Results From 5 Months!
This service starts soon! Be the first who get's notified when it begins!