22 lines
		
	
	
		
			No EOL
		
	
	
		
			347 B
		
	
	
	
		
			MQL5
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			No EOL
		
	
	
		
			347 B
		
	
	
	
		
			MQL5
		
	
	
	
	
	
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);
 | 
						|
  }
 | 
						|
}; |