Simple Moving Average (SMA)
Returns the Simple Moving Average, which calculates the arithmetic mean of closing prices over a specified period. SMA is one of the most widely used technical indicators for trend analysis.
Common SMA Periods
| Period | Usage |
|---|---|
| 10-day | Short-term trend |
| 20-day | Short-term trend |
| 50-day | Medium-term trend (golden/death cross) |
| 200-day | Long-term trend (golden/death cross) |
Parameters
| Parameter | Description | Default |
|---|---|---|
| Symbol | Stock ticker symbol | Required |
| Days | Number of periods for average | 30 |
| StartDate | Calculate SMA as of this date | Today |
Golden Cross / Death Cross
- Golden Cross: 50-day SMA crosses above 200-day SMA (bullish signal)
- Death Cross: 50-day SMA crosses below 200-day SMA (bearish signal)
Examples
=SimpleMovingAverage("AAPL")=SimpleMovingAverage("AAPL", "50")=SimpleMovingAverage("MSFT", "200")=SimpleMovingAverage("SPY", "20")=SimpleMovingAverage("AAPL", "50", DATE(2024,1,15))=SimpleMovingAverage(A1, B1)When to Use
- Identify trend direction (price above/below SMA)
- Calculate support and resistance levels
- Golden cross and death cross analysis
- Compare short-term vs long-term trends
- Smooth out price volatility for trend analysis
When NOT to Use
Common Issues & FAQ
Q: Why is SMA returning "NA"? A: Check that:
- The symbol is valid and actively traded
- There is sufficient historical data for the period specified
- The stock has been trading for at least the number of days requested
Q: What period should I use? A: Common periods:
- 10-20 days for short-term trading
- 50 days for medium-term analysis
- 200 days for long-term trend identification
Q: How does SMA differ from EMA? A: SMA gives equal weight to all prices in the period. EMA gives more weight to recent prices, making it more responsive to new information.
