Linear Weighted Moving Average?

Back to topics list To post a new topic, please log in or register
avatar
186
Yellowbeard 2015.03.06 20:43
 
Does anyone know where I can find a Linear Weighted Moving Average?

Thanks!
avatar
Moderator
3407
GumRai 2015.03.06 21:13 #
 
In the standard Moving Average that comes with MT4
avatar
186
Yellowbeard 2015.03.06 21:20 #
 

Want stand alone.  Looking for code.  So I can bring values into EA.

Thanks!

avatar
2017
gooly 2015.03.06 23:12 #
 
Read the editor's reference for iMA
avatar
32
pipPod 2015.03.07 07:13 #
 

In the MovingAverages.mqh header file.

//+------------------------------------------------------------------+
//| Linear Weighted Moving Average                                   |
//+------------------------------------------------------------------+
double LinearWeightedMA(const int position,const int period,const double &price[])
  {
//---
   double result=0.0,sum=0.0;
   int    i,wsum=0;
//--- calculate value
   if(position>=period-1 && period>0)
     {
      for(i=period;i>0;i--)
        {
         wsum+=i;
         sum+=price[position-i+1]*(period-i+1);
        }
      result=sum/wsum;
     }
//---
   return(result);
  }
Back to topics list  

To add comments, please log in or register