The Simple Moving Average indicator calculates the average of a series of values using a specific lookback period. The result is a line that moves along the data, representing a smoothed version of the source.
SMA mySMA50 = new SMA(bars.Close, 50);
SMA mySMA200 = SMA.Series(bars.Close, 200);
- source (TimeSeries)
- period (int)
For each trading period, the Simple Moving Average is the mean of the most recent "period" data points.
SMA = Sum(period data points) / period
- The trend is typically considered Bullish when prices are above the SMA.
- The trend is typically considered Bearish when prices are below the SMA.
- Bullish signals occur when a fast-period SMA crosses over a slow-period SMA.
- Bearish signals occur when a fast-period SMA crosses under a slow-period SMA.
- The 200-day SMA is a common standard indicator to indicate the long term trend.
- A Golden Cross occurs when the 50-day SMA crosses above the 200-day SMA.
- A Death Cross occurs when the 50-day SMA crosses below the 200-day SMA.
- In sideways markets, spurious SMA crossovers can occur frequently. This phenomenon is known as whipsaws.
Use the sliders below to control the periods of a fast SMA and a slow SMA. When the fast-period SMA crosses over the slow-period SMA, the chart background is colored green. When it crosses under, the chart background is colored red.