ATR Adaptive Laguerre Filter Levels Indicator For MT5

ATR Adaptive Laguerre Filter Levels Indicator For MT5

The ATR Adaptive Laguerre Filter Levels Indicator For MT5 draws nice bands onto the chart which act as support and resistance. A special smoothing algorithm makes this indicator less reactive to insignificant market moves and therefore you will be able to hold the trades longer. Green color is used for upward trends and red color is used for downward trends. Pullbacks behind the band (without changing the color) and then a continuation of the trend seem to be great trading setups.

FREE ATR adaptive Laguerre filter - levels Indicator

Download the FREE ATR adaptive Laguerre filter - levels Indicator for MT5.

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

 

Installing the ATR Adaptive Laguerre Filter Levels 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 ATR adaptive Laguerre filter levels.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 ATR Adaptive Laguerre Filter Levels Indicator For MT5

The ATR Adaptive Laguerre Filter Levels Indicator For MT5 has 4 parameters to configure.

input double             inpPeriod  = 14;            // Period
input double             inpPeriodl =  0;            // Levels period (<=1 for same as filter period)
input ENUM_APPLIED_PRICE inpPrice   = PRICE_CLOSE;   // Price
input enDisplayFill      inpDisplay = fill_display;  // Filled zones display :

Buffers of the ATR Adaptive Laguerre Filter Levels Indicator For MT5

The ATR Adaptive Laguerre Filter Levels Indicator For MT5 provides 7 buffers.

SetIndexBuffer(0,fillu,INDICATOR_DATA);
SetIndexBuffer(1,filld,INDICATOR_DATA);
SetIndexBuffer(2,levelUp,INDICATOR_DATA);
SetIndexBuffer(3,levelDn,INDICATOR_DATA);
SetIndexBuffer(4,val,INDICATOR_DATA);
SetIndexBuffer(5,valc,INDICATOR_COLOR_INDEX);
SetIndexBuffer(6,atr,INDICATOR_CALCULATIONS);

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(BarsCalculated(_atrHandle) lt rates_total) return(prev_calculated);
   
   //
   //---
   //
      
      int _copyCount = MathMin(rates_total-prev_calculated+1,rates_total);
            if (CopyBuffer(_atrHandle,0,0,_copyCount,atr)!=_copyCount) return(prev_calculated);
   
   //
   //---
   //

   int i=(int)MathMax(prev_calculated-1,0); for(; i lt rates_total && !_StopFlag; i++)
   {
      int    _start = MathMax(i-_atrPeriod+1,0);
      double _max   = atr[ArrayMaximum(atr,_start,_atrPeriod)];            
      double _min   = atr[ArrayMinimum(atr,_start,_atrPeriod)];            
      double _coeff = (_min!=_max) ? 1-(atr[i]-_min)/(_max-_min) : 0.5;
             _coeff = (_coeff+1.0)/2.0;
  
      val[i] = iLaGuerreFil(getPrice(inpPrice,open,close,high,low,i),inpPeriod*_coeff,i,0);
         double _levelUp = iLaGuerreFil(val[i],_levelsPeriod*_coeff,i,1,(i gt 0 ? !(val[i] gt levelDn[i-1]) : false));
         double _levelDn = iLaGuerreFil(val[i],_levelsPeriod*_coeff,i,2,(i gt 0 ? !(val[i] lt levelUp[i-1]) : false));
      levelUp[i] = MathMax(_levelUp,_levelDn);
      levelDn[i] = MathMin(_levelUp,_levelDn);
      valc[i]    = (val[i] gt levelUp[i]) ? 1 : (val[i] lt levelDn[i]) ? 2 : (i gt 0) ? (val[i]==val[i-1]) ? valc[i-1]: 0 : 0;
      fillu[i]   = (inpDisplay==fill_dont) ? EMPTY_VALUE : val[i];
      filld[i]   = (inpDisplay==fill_dont) ? EMPTY_VALUE : (valc[i]==0) ? val[i] : (valc[i]==1) ? levelUp[i] : levelDn[i];
   }
   return(i);
}

//+------------------------------------------------------------------+
//| Custom functions                                                 |
//+------------------------------------------------------------------+
#define _lagFilInstances 3
#define _lagFilInstancesSize 4
#define _lagFilRingSize 6
double workLagFil[_lagFilRingSize][_lagFilInstances*_lagFilInstancesSize];
double iLaGuerreFil(double price, double period, int i, int instance=0, bool copy=false)
{
   int _indC = (i  )%_lagFilRingSize;
   int _indP = (i-1)%_lagFilRingSize;
   int _inst = instance*_lagFilInstancesSize;

      //
      //---
      //

      if (!copy && i gt 0 && period gt 1)
      {      
         double _gamma = 1.0 - 10.0/(period+9.0);
            workLagFil[_indC][_inst  ] =  price                      + _gamma*(workLagFil[_indP][_inst  ] - price                     );
            workLagFil[_indC][_inst+1] =  workLagFil[_indP][_inst  ] + _gamma*(workLagFil[_indP][_inst+1] - workLagFil[_indC][_inst  ]);
            workLagFil[_indC][_inst+2] =  workLagFil[_indP][_inst+1] + _gamma*(workLagFil[_indP][_inst+2] - workLagFil[_indC][_inst+1]);
            workLagFil[_indC][_inst+3] =  workLagFil[_indP][_inst+2] + _gamma*(workLagFil[_indP][_inst+3] - workLagFil[_indC][_inst+2]);
      }
      else for (int k=0; k lt _lagFilInstancesSize; k++) workLagFil[_indC][_inst+k]= (copy && i gt 0) ? workLagFil[_indP][_inst+k] : price;

      //
      //---
      //

   return((workLagFil[_indC][_inst]+2.0*workLagFil[_indC][_inst+1]+2.0*workLagFil[_indC][_inst+2]+workLagFil[_indC][_inst+3])/6.0);
}
//
//---
//
double getPrice(ENUM_APPLIED_PRICE tprice,const double &open[],const double &close[],const double &high[],const double &low[],int i)
  {
   if(i gt =0)
      switch(tprice)
        {
         case PRICE_CLOSE:     return(close[i]);
         case PRICE_OPEN:      return(open[i]);
         case PRICE_HIGH:      return(high[i]);
         case PRICE_LOW:       return(low[i]);
         case PRICE_MEDIAN:    return((high[i]+low[i])/2.0);
         case PRICE_TYPICAL:   return((high[i]+low[i]+close[i])/3.0);
         case PRICE_WEIGHTED:  return((high[i]+low[i]+close[i]+close[i])/4.0);
        }
   return(0);
  }
//
//---
//  
bool _checkHandle(int _handle)
{
   static int _handles[];
          int _size = ArraySize(_handles);
          
          if (_handle!=INVALID_HANDLE) 
          { 
               ArrayResize(_handles,_size+1); 
                           _handles[_size]=_handle; 
                                 return(true); 
          }
          for (int i=_size-1; i gt 0; i--)
               IndicatorRelease(_handles[i]); ArrayResize(_handles,0);
          return(false);
}  
//+------------------------------------------------------------------+

 

 

 

 

 

 

 

 

 

 

 

 

Trend Intensity Index Indicator For MT5

Trend Intensity Index Indicator For MT5

The Trend Intensity Index Indicator For MT5 was developed by M.H. Pee and is based on the 60 period Simple Moving Average. The indicator draws an oscillator on an indicator subwindow that swings between 0 and 100. The indicator detects the direction of the trend as well as overbought/oversold conditions. Dynamic support and resistance zones are used to detect extreme overbought and oversold conditions.

FREE Trend Intensity Index Indicator

Download the FREE Trend Intensity Index Indicator for MT5.

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

 

Installing the Trend Intensity Index 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 Trend intensity index.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 Trend Intensity Index Indicator For MT5

The Trend Intensity Index Indicator For MT5 has 5 parameters to configure.

input int                inpLength     = 30;           // Trend intensity index period
input ENUM_APPLIED_PRICE inpPrice      = PRICE_CLOSE;  // Price
input ENUM_MA_METHOD     inpMaMode     = MODE_SMA;     // Average method
input double             inpLevelHigh  = 80;           // Level high
input double             inpLevelLow   = 20;           // Level low

Buffers of the Trend Intensity Index Indicator For MT5

The Trend Intensity Index Indicator For MT5 provides 6 buffers.

SetIndexBuffer(0,levup,INDICATOR_DATA);
SetIndexBuffer(1,levdn,INDICATOR_DATA);
SetIndexBuffer(2,val,INDICATOR_DATA);
SetIndexBuffer(3,valc,INDICATOR_COLOR_INDEX);
SetIndexBuffer(4,prices,INDICATOR_CALCULATIONS);
SetIndexBuffer(5,state,INDICATOR_CALCULATIONS);

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);
   if(BarsCalculated(_maHandle) lt rates_total) return(prev_calculated);
   int i=(int)MathMax(prev_calculated-1,0); for(; i lt rates_total && !_StopFlag; i++)
     {
      double _maVal[1];
      int    _maCopied=CopyBuffer(_maHandle,0,time[i],1,_maVal);
      double ma =  (_maCopied==1) ? _maVal[0] : 0;
      prices[i] = getPrice(inpPrice,open,close,high,low,i,rates_total);

      //
      //---
      //

      double sumUpDeviations = 0;
      double sumDnDeviations = 0;
      for(int j=0; j lt inpLength && (i-j) gt =0; j++)
        {
         double diff=prices[i-j]-ma;
         if(diff gt 0)
            sumUpDeviations += diff;
         else  sumDnDeviations -= diff;
        }

      //
      //
      //
      //
      //

      val[i]   = ((sumUpDeviations+sumDnDeviations)!=0) ? 100*sumUpDeviations/(sumUpDeviations+sumDnDeviations) : 0;
      levdn[i] = 50;
      levup[i] = (val[i] gt inpLevelHigh) ? 100: (val[i] lt inpLevelLow) ? 0 : 50;
      valc[i]  = (val[i] gt inpLevelHigh) ? 2 : (val[i] lt inpLevelLow) ? 1 : 0;
     }
   return (i);
  }
//+------------------------------------------------------------------+
//| Custom functions                                                 |
//+------------------------------------------------------------------+
double getPrice(ENUM_APPLIED_PRICE tprice,const double &open[],const double &close[],const double &high[],const double &low[],int i,int _bars)
  {
   switch(tprice)
     {
      case PRICE_CLOSE:     return(close[i]);
      case PRICE_OPEN:      return(open[i]);
      case PRICE_HIGH:      return(high[i]);
      case PRICE_LOW:       return(low[i]);
      case PRICE_MEDIAN:    return((high[i]+low[i])/2.0);
      case PRICE_TYPICAL:   return((high[i]+low[i]+close[i])/3.0);
      case PRICE_WEIGHTED:  return((high[i]+low[i]+close[i]+close[i])/4.0);
     }
   return(0);
  }
//+------------------------------------------------------------------+

 

 

 

 

 

 

 

 

 

 

 

 

Table of Contents

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

Volume Rate of Change VROC Indicator For MT5

Volume Rate of Change VROC Indicator For MT5

The Volume Rate of Change VROC Indicator For MT5 measures the volume of the current bar and compares that volume with the volume of the recent x bars. On rising volume you will see positive values. On declining volume you will see negative values. At key market situations like breakouts and reversals you will usually see a high volume. Many traders use high volume to confirm their entry into the market moves.

FREE Volume Rate of Change (VROC) Indicator

Download the FREE Volume Rate of Change (VROC) Indicator for MT5.

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

 

Installing the Volume Rate of Change VROC 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 vroc.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 Volume Rate of Change VROC Indicator For MT5

The Volume Rate of Change VROC Indicator For MT5 has 2 parameters to configure.

input int                 InpPeriodVROC=25;           // Period
input ENUM_APPLIED_VOLUME InpVolumeType=VOLUME_TICK;  // Volumes

Buffers of the Volume Rate of Change VROC Indicator For MT5

The Volume Rate of Change VROC Indicator For MT5 provides 1 buffers.

SetIndexBuffer(0,ExtVROCBuffer);

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 &TickVolume[],
                const long &Volume[],
                const int &Spread[])
  {
//--- check for rates count
   if(rates_total lt ExtPeriodVROC)
      return(0);
//--- starting work
   int pos=prev_calculated-1;
//--- initializing ExtVROCBuffer
   if(pos lt ExtPeriodVROC-1) pos=ExtPeriodVROC-1;
//--- main cycle by volume type
   if(InpVolumeType==VOLUME_TICK)
      CalculateVROC(pos,rates_total,TickVolume);
   else
      CalculateVROC(pos,rates_total,Volume);
//---- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Calculate VROC by volume argument                                |
//+------------------------------------------------------------------+
void CalculateVROC(const int nPosition,
                   const int nRatesCount,
                   const long &VolBuffer[])
  {
   for(int i=nPosition;i lt nRatesCount && !IsStopped();i++)
     {
      //--- getting some data
      double PrevVolume=(double)(VolBuffer[i-(ExtPeriodVROC-1)]);
      double CurrVolume=(double)VolBuffer[i];
      //--- fill ExtVROCBuffer
      if(PrevVolume!=0.0)
         ExtVROCBuffer[i]=100.0*(CurrVolume-PrevVolume)/PrevVolume;
      else
         ExtVROCBuffer[i]=ExtVROCBuffer[i-1];
     }
  }
//+------------------------------------------------------------------+

 

 

 

 

 

 

 

 

 

 

 

 

Flat_Trend Indicator For MT5

Flat_Trend Indicator For MT5

The Flat_Trend Indicator For MT5 draws 4 states of the trend on an oscillator subwindow. To determine the state of the trend the well known ADX and the Parabolic Sar indicator are used. Red value is drawn if the DMI and the parabolic sar are pointing downward. Green value is used if the DMI and the parabolic sar are pointing upward. If DMI shows upward but the parabolic sar downward then light green is used. If the DMI points downward and the parabolic sar points upward then orange color is used.

FREE Flat_Trend Indicator

Download the FREE Flat_Trend Indicator for MT5.

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

 

Installing the Flat_Trend 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 Flat_Trend.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 Flat_Trend Indicator For MT5

The Flat_Trend Indicator For MT5 has 3 parameters to configure.

input double               InpStepSAR        =  0.02;          // SAR step
input double               InpMaxSAR         =  0.2;           // SAR max
input uint                 InpPeriodDMI      =  14;            // ADX period

Buffers of the Flat_Trend Indicator For MT5

The Flat_Trend Indicator For MT5 provides 7 buffers.

SetIndexBuffer(0,BufferUpUp,INDICATOR_DATA);
SetIndexBuffer(1,BufferUpDn,INDICATOR_DATA);
SetIndexBuffer(2,BufferDnUp,INDICATOR_DATA);
SetIndexBuffer(3,BufferDnDn,INDICATOR_DATA);
SetIndexBuffer(4,BufferPDI,INDICATOR_CALCULATIONS);
SetIndexBuffer(5,BufferMDI,INDICATOR_CALCULATIONS);
SetIndexBuffer(6,BufferSAR,INDICATOR_CALCULATIONS);

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[])
  {
//--- #AB0= gt 2:0  lt 0AA82 gt 2 1CD5@ gt 2 :0: B09 lt A5@89
   ArraySetAsSeries(low,true);
//--- @ gt 25@:0 8 @0AGQB : gt ;8G5AB20 ?@ gt AG8BK205 lt KE 10@ gt 2
   if(rates_total lt 4) return 0;
//--- @ gt 25@:0 8 @0AGQB : gt ;8G5AB20 ?@ gt AG8BK205 lt KE 10@ gt 2
   int limit=rates_total-prev_calculated;
   if(limit gt 1)
     {
      limit=rates_total-1;
      ArrayInitialize(BufferUpUp,EMPTY_VALUE);
      ArrayInitialize(BufferUpDn,EMPTY_VALUE);
      ArrayInitialize(BufferDnUp,EMPTY_VALUE);
      ArrayInitialize(BufferDnDn,EMPTY_VALUE);
      ArrayInitialize(BufferPDI,0);
      ArrayInitialize(BufferMDI,0);
      ArrayInitialize(BufferSAR,0);
     }
//---  gt 43 gt B gt 2:0 40==KE
   int count=(limit gt 1 ? rates_total : 1),copied=0;
   copied=CopyBuffer(handle_adx,PLUSDI_LINE,0,count,BufferPDI);
   if(copied!=count) return 0;
   copied=CopyBuffer(handle_adx,MINUSDI_LINE,0,count,BufferMDI);
   if(copied!=count) return 0;
   copied=CopyBuffer(handle_sar,0,0,count,BufferSAR);
   if(copied!=count) return 0;
   
//---  0AGQB 8=48:0B gt @0
   for(int i=limit; i gt =0 && !IsStopped(); i--)
     {
      double PDI=BufferPDI[i];
      double MDI=BufferMDI[i];
      double SAR=BufferSAR[i];

      bool one=(PDI gt MDI ? true : false);
      bool two=(SAR gt low[i] ? false : true);

      BufferUpUp[i]=BufferUpDn[i]=BufferDnUp[i]=BufferDnDn[i]=EMPTY_VALUE;

      if(one)
        {
         if(two)
            BufferUpUp[i]=0.5;
         else
            BufferUpDn[i]=0.5;
        }
      else
        {
         if(two)
            BufferDnUp[i]=0.5;
         else
            BufferDnDn[i]=0.5;
        }
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_CHART_CHANGE)
     {
      for(int i=0;i lt 4;i++)
         PlotIndexSetInteger(i,PLOT_LINE_WIDTH,SizeByScale());
      Descriptions();
      ChartRedraw();
     }
  }
//+------------------------------------------------------------------+
//|  gt 72@0I05B @07 lt 5@, A gt  gt B25BAB2CNI89  lt 0AHB01C                      |
//+------------------------------------------------------------------+
uchar SizeByScale(void)
  {
   uchar scale=(uchar)ChartGetInteger(0,CHART_SCALE);
   uchar size=(scale lt 3 ? 1 : scale==3 ? 2 : scale==4 ? 5 : 8);
   return size;
  }
//+------------------------------------------------------------------+
//| ?8A0=85                                                         |
//+------------------------------------------------------------------+
void Descriptions(void)
  {
   int x=4;
   int y=1;
   int arr_colors[]={indicator_color1,indicator_color2,indicator_color3,indicator_color4};
   string arr_texts[]={"DMI up, SAR up","DMI up, SAR down","DMI down, SAR up","DMI down, SAR down"};
   string arr_names[4];
   for(int i=0; i lt 4; i++)
     {
      arr_names[i]=prefix+"label"+(string)i;
      arr_colors[i]=PlotIndexGetInteger(i,PLOT_LINE_COLOR);
      x=(i==0 ? x : i==1 ? 110 : i==2 ? 230 : 350);
      Label(arr_names[i],x,y,CharToString(167),16,arr_colors[i],"Wingdings");
      Label(arr_names[i]+"_txt",x+10,y+5,arr_texts[i],10,clrGray,"Calibri");
     }
  }
//+------------------------------------------------------------------+
//| K2 gt 48B B5:AB gt 2CN  lt 5B:C                                          |
//+------------------------------------------------------------------+
void Label(const string name,const int x,const int y,const string text,const int size,const color clr,const string font)
  {
   if(ObjectFind(0,name)!=wnd)
      ObjectCreate(0,name,OBJ_LABEL,wnd,0,0,0,0);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_LOWER);
   ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_LEFT_LOWER);
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,size);
   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//---
   ObjectSetString(0,name,OBJPROP_FONT,font);
   ObjectSetString(0,name,OBJPROP_TEXT,text);
   ObjectSetString(0,name,OBJPROP_TOOLTIP,"
");
  }
//+------------------------------------------------------------------+

 

 

 

 

 

 

 

 

 

 

 

 

Table of Contents

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

Super Trend Averages Indicator For MT5

Super Trend Averages Indicator For MT5

The Super Trend Averages Indicator For MT5 is based on the famous supertrend indicator. It extends the functionality of the original indicator and allows to select 18 different moving average calculations.

FREE Super Trend Averages Indicator

Download the FREE Super Trend Averages Indicator for MT5.

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

 

Installing the Super Trend Averages 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 super_trend_averages.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 Super Trend Averages Indicator For MT5

The Super Trend Averages Indicator For MT5 has 5 parameters to configure.

input int              AvgPeriod     = 12;        // Averages period
input enumAveragesType AvgMethod     = avgHull;   // Averages method
input enPrices         Price         = pr_median; // Price
input int              atrPeriod     = 12;        // ATR period
input double           atrMultiplier = 0.66;      // ATR multiplier

Buffers of the Super Trend Averages Indicator For MT5

The Super Trend Averages Indicator For MT5 provides 2 buffers.

SetIndexBuffer(0,st,INDICATOR_DATA);
SetIndexBuffer(1,colorBuffer,INDICATOR_COLOR_INDEX);

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[])
{
   totalBars=rates_total;
   if (ArraySize(Direction)!=rates_total)
   {
      ArrayResize(Up,rates_total);
      ArrayResize(Dn,rates_total);
      ArrayResize(Direction,rates_total);
   }      

   //
   //
   //
   //
   //

   for (int i=(int)MathMax(prev_calculated-1,1); i lt rates_total; i++)
   {
      double atr = 0; 
         for (int k=0;k lt atrPeriod && (i-k-1) gt =0; k++) 
               atr += MathMax(high[i-k],close[i-k-1])-MathMin(low[i-k],close[i-k-1]);
               atr /= atrPeriod;
      
         //
         //
         //
         //
         //
      
         double cprice = close[i];
         double mprice = iCustomMa(AvgMethod,getPrice(Price,open,close,high,low,i,rates_total),AvgPeriod,tick_volume,i);
                Up[i]  = mprice+atrMultiplier*atr;
                Dn[i]  = mprice-atrMultiplier*atr;
         
         //
         //
         //
         //
         //

         colorBuffer[i] = colorBuffer[i-1];
         Direction[i]   = Direction[i-1];
            if (cprice  gt  Up[i-1]) Direction[i] =  1;
            if (cprice  lt  Dn[i-1]) Direction[i] = -1;
            if (Direction[i]  gt  0) 
                  { Dn[i] = MathMax(Dn[i],Dn[i-1]); st[i] = Dn[i]; }
            else  { Up[i] = MathMin(Up[i],Up[i-1]); st[i] = Up[i]; }
            if (Direction[i]== 1) colorBuffer[i] = 0;
            if (Direction[i]==-1) colorBuffer[i] = 1;
   }
   return(rates_total);
}


//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

string methodNames[] = {"SMA","EMA","Double smoothed EMA","Double EMA","Tripple EMA","Smoothed MA","Linear weighted MA","Parabolic weighted MA","Alexander MA","Volume weghted MA","Hull MA","Triangular MA","Sine weighted MA","Linear regression","IE/2","NonLag MA","Zero lag EMA","Leader EMA"};
string getAverageName(int method)
{
   int max = ArraySize(methodNames)-1;
      method = (int)MathMax(MathMin(method,max),0); return(methodNames[method]);
}

//
//
//
//
//

#define _maWorkBufferx1 1
#define _maWorkBufferx2 2
#define _maWorkBufferx3 3

double iCustomMa(int mode, double price, double length, const long& Volume[], int r, int instanceNo=0)
{
   switch (mode)
   {
      case avgSma   : return(iSma(price,(int)length,r,instanceNo));
      case avgEma   : return(iEma(price,length,r,instanceNo));
      case avgDsema : return(iDsema(price,length,r,instanceNo));
      case avgDema  : return(iDema(price,length,r,instanceNo));
      case avgTema  : return(iTema(price,length,r,instanceNo));
      case avgSmma  : return(iSmma(price,length,r,instanceNo));
      case avgLwma  : return(iLwma(price,length,r,instanceNo));
      case avgPwma  : return(iLwmp(price,length,r,instanceNo));
      case avgAlex  : return(iAlex(price,length,r,instanceNo));
      case avgVwma  : return(iWwma(price,length,Volume,r,instanceNo));
      case avgHull  : return(iHull(price,length,r,instanceNo));
      case avgTma   : return(iTma(price,length,r,instanceNo));
      case avgSine  : return(iSineWMA(price,(int)length,r,instanceNo));
      case avgLsma  : return(iLinr(price,length,r,instanceNo));
      case avgIe2   : return(iIe2(price,length,r,instanceNo));
      case avgNlma  : return(iNonLagMa(price,length,r,instanceNo));
      case avgZlma  : return(iZeroLag(price,length,r,instanceNo));
      case avgLead  : return(iLeader(price,length,r,instanceNo));
      default : return(price);
   }
}

//------------------------------------------------------------------
//                                                                  
//------------------------------------------------------------------
//
//
//
//
//

double workSma[][_maWorkBufferx2];
double iSma(double price, int period, int r, int instanceNo=0)
{
   if (ArrayRange(workSma,0)!= totalBars) ArrayResize(workSma,totalBars); instanceNo *= 2;

   //
   //
   //
   //
   //

   int k;      
   workSma[r][instanceNo] = price;
   if (r gt =period)
          workSma[r][instanceNo+1] = workSma[r-1][instanceNo+1]+(workSma[r][instanceNo]-workSma[r-period][instanceNo])/period;
   else { workSma[r][instanceNo+1] = 0; for(k=0; k lt period && (r-k) gt =0; k++) workSma[r][instanceNo+1] += workSma[r-k][instanceNo];  
          workSma[r][instanceNo+1] /= k; }
   return(workSma[r][instanceNo+1]);
}

//
//
//
//
//

double workEma[][_maWorkBufferx1];
double iEma(double price, double period, int r, int instanceNo=0)
{
   if (ArrayRange(workEma,0)!= totalBars) ArrayResize(workEma,totalBars);

   //
   //
   //
   //
   //
      
   double alpha = 2.0 / (1.0+period);
          workEma[r][instanceNo] = workEma[r-1][instanceNo]+alpha*(price-workEma[r-1][instanceNo]);
   return(workEma[r][instanceNo]);
}

//
//
//
//
//

double workDsema[][_maWorkBufferx2];
#define _ema1 0
#define _ema2 1
double iDsema(double price, double period, int r, int instanceNo=0)
{
   if (ArrayRange(workDsema,0)!= totalBars) ArrayResize(workDsema,totalBars); instanceNo*=2;

   //
   //
   //
   //
   //
      
   double alpha = 2.0 /(1.0+MathSqrt(period));
          workDsema[r][_ema1+instanceNo] = workDsema[r-1][_ema1+instanceNo]+alpha*(price                         -workDsema[r-1][_ema1+instanceNo]);
          workDsema[r][_ema2+instanceNo] = workDsema[r-1][_ema2+instanceNo]+alpha*(workDsema[r][_ema1+instanceNo]-workDsema[r-1][_ema2+instanceNo]);
   return(workDsema[r][_ema2+instanceNo]);
}

//
//
//
//
//

double workDema[][_maWorkBufferx2];
double iDema(double price, double period, int r, int instanceNo=0)
{
   if (ArrayRange(workDema,0)!= totalBars) ArrayResize(workDema,totalBars); instanceNo*=2;

   //
   //
   //
   //
   //
      
   double alpha = 2.0 / (1.0+period);
          workDema[r][_ema1+instanceNo] = workDema[r-1][_ema1+instanceNo]+alpha*(price                        -workDema[r-1][_ema1+instanceNo]);
          workDema[r][_ema2+instanceNo] = workDema[r-1][_ema2+instanceNo]+alpha*(workDema[r][_ema1+instanceNo]-workDema[r-1][_ema2+instanceNo]);
   return(workDema[r][_ema1+instanceNo]*2.0-workDema[r][_ema2+instanceNo]);
}

//
//
//
//
//

double workTema[][_maWorkBufferx3];
#define _ema3 2
double iTema(double price, double period, int r, int instanceNo=0)
{
   if (ArrayRange(workTema,0)!= totalBars) ArrayResize(workTema,totalBars); instanceNo*=3;

   //
   //
   //
   //
   //
      
   double alpha = 2.0 / (1.0+period);
          workTema[r][_ema1+instanceNo] = workTema[r-1][_ema1+instanceNo]+alpha*(price                        -workTema[r-1][_ema1+instanceNo]);
          workTema[r][_ema2+instanceNo] = workTema[r-1][_ema2+instanceNo]+alpha*(workTema[r][_ema1+instanceNo]-workTema[r-1][_ema2+instanceNo]);
          workTema[r][_ema3+instanceNo] = workTema[r-1][_ema3+instanceNo]+alpha*(workTema[r][_ema2+instanceNo]-workTema[r-1][_ema3+instanceNo]);
   return(workTema[r][_ema3+instanceNo]+3.0*(workTema[r][_ema1+instanceNo]-workTema[r][_ema2+instanceNo]));
}

//
//
//
//
//

double workSmma[][_maWorkBufferx1];
double iSmma(double price, double period, int r, int instanceNo=0)
{
   if (ArrayRange(workSmma,0)!= totalBars) ArrayResize(workSmma,totalBars);

   //
   //
   //
   //
   //

   if (r lt period)
         workSmma[r][instanceNo] = price;
   else  workSmma[r][instanceNo] = workSmma[r-1][instanceNo]+(price-workSmma[r-1][instanceNo])/period;
   return(workSmma[r][instanceNo]);
}

//
//
//
//
//

double workLwma[][_maWorkBufferx1];
double iLwma(double price, double period, int r, int instanceNo=0)
{
   if (ArrayRange(workLwma,0)!= totalBars) ArrayResize(workLwma,totalBars);
   
   //
   //
   //
   //
   //
   
   workLwma[r][instanceNo] = price;
      double sumw = period;
      double sum  = period*price;

      for(int k=1; k lt period && (r-k) gt =0; k++)
      {
         double weight = period-k;
                sumw  += weight;
                sum   += weight*workLwma[r-k][instanceNo];  
      }             
      return(sum/sumw);
}

//
//
//
//
//

double workLwmp[][_maWorkBufferx1];
double iLwmp(double price, double period, int r, int instanceNo=0)
{

 

 

 

 

 

 

 

 

 

 

 

 

Table of Contents

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

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:  

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