sma
Syntax
sma(X, window)
Please see TALib for the parameters and windowing logic.
Details
Calculate the Simple Moving Average (sma) for X in a sliding window of the given length.
The formula is: 
Note:
DolphinDB sma and TA-Lib SMA use essentially
the same calculation method. The primary differences lie in the execution
environment and supported data structures. DolphinDB sma is a
built-in TA-Lib function that operates on vectors or matrices in DolphinDB
scripts and SQL, whereas TA-Lib SMA is a function that
typically processes one-dimensional price series.
Returns
A DOUBLE vector.
Examples
x=12.1 12.2 12.6 12.8 11.9 11.6 11.2
sma(x,3);
// output: [,,12.299999999999998,12.533333333333331,12.433333333333331,12.099999999999999,11.566666666666664]
x=matrix(12.1 12.2 12.6 12.8 11.9 11.6 11.2, 14 15 18 19 21 12 10)
sma(x,3);
| col1 | col2 |
|---|---|
| 12.3 | 15.6667 |
| 12.5333 | 17.3333 |
| 12.4333 | 19.3333 |
| 12.1 | 17.3333 |
| 11.5667 | 14.3333 |
