What it measures
A simple moving average adds up the last period closes (20 by default) and divides by period. Every close in the window counts equally, and each new bar drops the oldest one.
How to read it
- Direction. The average rises on a bar when the new close is higher than the close dropping out of the window, so a steadily rising average reflects generally higher prices over the period.
- Price versus the average. Price above a rising average is a common definition of an uptrend. The 50-day and 200-day averages are widely watched on daily charts.
- Crossovers. A shorter average crossing above a longer one (for example 50 over 200, the "golden cross") is a classic trend signal; crossing below is the "death cross".
Common mistakes
- Expecting it to lead. A moving average lags by design: the longer the period, the later it turns.
- Reacting to the drop-off. Because the oldest close leaves the window each bar, an unusually large old bar leaving can move the average even when today's price barely changes.
Use it in a scan
Price above a 50-day average that is higher than five bars ago:
c > sma(c, 50) and sma(c, 50) > sma(c, 50)@5
A golden cross:
cross_up(sma(c, 50), sma(c, 200))Inputs
| Input | Type | Default | Range |
|---|---|---|---|
period | integer | 20 | 2 – 300 |
Outputs
value
References
- StockVyze SKIF language reference: simple moving average
