Simple Moving Average (SMA)
Simple Moving Average is the average price over a lookback window. An extended analysis option includes mean absolute deviation (MAD), mean square error (MSE), and mean absolute percentage error (MAPE). [Discuss] 💬

// C# usage syntax (with Close price)
IEnumerable<SmaResult> results =
quotes.GetSma(lookbackPeriods);
Parameters
lookbackPeriods int - Number of periods (N) in the lookback window. Must be greater than 0.
Historical quotes requirements
You must have at least N periods of quotes to cover the warmup periods.
quotes is a collection of generic TQuote historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.
Response
IEnumerable<SmaResult>
- This method returns a time series of all available indicator values for the
quotesprovided. - It always returns the same number of elements as there are in the historical quotes.
- It does not return a single incremental indicator value.
- The first
N-1periods will havenullvalues since there’s not enough data to calculate.
SmaResult
Date DateTime - Date from evaluated TQuote
Sma double - Simple moving average
Utilities
See Utilities and helpers for more information.
Analysis
This indicator has an extended version with more analysis.
// C# usage syntax
IEnumberable<SmaAnalysis> analysis =
results.GetSmaAnalysis();
SmaAnalysis
Date DateTime - Date from evaluated TQuote
Sma decimal - Simple moving average
Mad double - Mean absolute deviation
Mse double - Mean square error
Mape double - Mean absolute percentage error
Chaining
This indicator may be generated from any chain-enabled indicator or method.
// example
var results = quotes
.Use(CandlePart.Volume)
.GetSma(..);
Results can be further processed on Sma with additional chain-enabled indicators.
// example
var results = quotes
.GetSma(..)
.GetRsi(..);