Some of you might've already heard of the Kaufman Efficiency Ratio as it can be an effective filter for Reversal/Mean-Reversion trading.
My idea of using the indicator is quite simple, I want to have a filter line that tells when market's volatility is above or below the trading objective.
And so instead of having a static line like this:


Problem is I've been trying to put together an EA using a software that doesn't require coding knowledge but this particular one with two indis being used as one is a challenging case.
Hope everybody finding this useful and happy to give me hand with the coding.
Thanks for reading!
mql4 MA Codes:
Code: Select all
//+------------------------------------------------------------------+
//| Simple Moving Average |
//+------------------------------------------------------------------+
double SimpleMA(const int position,const int period,const double &price[])
{
//---
double result=0.0;
//--- check position
if(position>=period-1 && period>0)
{
//--- calculate value
for(int i=0;i<period;i++) result+=price[position-i];
result/=period;
}
//---
return(result);
}
//+------------------------------------------------------------------+
//| Exponential Moving Average |
//+------------------------------------------------------------------+
double ExponentialMA(const int position,const int period,const double prev_value,const double &price[])
{
//---
double result=0.0;
//--- calculate value
if(period>0)
{
double pr=2.0/(period+1.0);
result=price[position]*pr+prev_value*(1-pr);
}
//---
return(result);
}
//+------------------------------------------------------------------+
//| Smoothed Moving Average |
//+------------------------------------------------------------------+
double SmoothedMA(const int position,const int period,const double prev_value,const double &price[])
{
//---
double result=0.0;
//--- check position
if(period>0)
{
if(position==period-1)
{
for(int i=0;i<period;i++) result+=price[position-i];
result/=period;
}
if(position>=period)
result=(prev_value*(period-1)+price[position])/period;
}
//---
return(result);
}
//+------------------------------------------------------------------+
//| 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);
}