What is a SMA (simple moving average)?
A simple moving average (SMA) is the plain mean of the last N values of a price series, recalculated on every bar so the line travels with price.
Our SMA draws up to six lines on the price pane; the defaults are 20, 50 and 200 bars, a short, medium and long view of the same trend. It reads the close unless you pick another price field (open, high, low, hl2, hlc3, ohlc4) or another indicator as the source. Each line starts only once N bars are loaded.
How is a SMA calculated?
SMA(N) = (P[t] + P[t-1] + ... + P[t-N+1]) / N
The terms in the formula
- P[t]
- Source value on bar t (the close by default).
- N
- Length in bars: 20, 50 and 200 by default, up to six lines.
- t
- The current bar.
How do you read a SMA?
- Price above a rising SMA is commonly read as an uptrend, price below a falling one as a downtrend; a flat line suggests a range.
- The slope says more than a single touch: a 200-bar line that has turned up describes a slow, long change of direction.
- A shorter line crossing above a longer one (50 over 200 is often called a golden cross) means recent prices now average above older ones; the reverse cross is often called a death cross.
- The gap between price and a line shows how stretched a move is relative to its own average.
What are the limits of a SMA?
- Every bar in the window weighs the same, so the line lags: a 200-bar SMA can trail a turn by months.
- In sideways markets price crosses the line back and forth, and most of those crosses lead nowhere.
- The bar leaving the window moves the line as much as the new bar, so the line can bend for reasons unrelated to today.
- The bar size matters: 200 bars is about ten months on a daily chart but almost four years on a weekly one.
Where can you see it on TickerBase?
Open a live chart and add the indicator