TesterEA_by_fxsaber/Experts/fxsaber/TesterEA/EMA.mqh

22 lines
347 B
MQL5
Raw Permalink Normal View History

struct EMA
{
private:
double Value;
public:
const double Alpha;
EMA( const int period ) : Alpha(1.0 / period), Value(0)
{
}
double Get( const double NewValue )
{
if (this.Value)
this.Value += (NewValue - this.Value) * this.Alpha;
else
this.Value = NewValue;
return(this.Value);
}
};