← Back to Library
Trend

Simple Moving Average (SMA)

The SMA calculates the average of a selected range of prices by the number of periods in that range. It is the most fundamental trend indicator.

Pine Script V6
//@version=6
indicator('SMA', overlay=true)
len = input.int(9, 'Length')
plot(ta.sma(close, len), 'SMA', color=color.blue)