Simple Moving Average (SMA)
Plots the plain average of the last N closing prices as a line on the price chart.
What you see
A single line on the price chart. Each point is the average close of the last Period candles, the current candle included. The line starts on the Period-th loaded candle; before that there is no value.
How it is calculated
SMA = (sum of the last N closes) / N, with N = Period.
Every close in the window has the same weight. With each new candle the oldest close drops out of the window and the newest one comes in.
How to read it
- Price above a rising SMA points to an uptrend, price below a falling SMA to a downtrend. A flat SMA that price keeps crossing signals a range.
- A longer period gives a smoother line that reacts later; a shorter period follows price closely but produces more false signals.
- Two SMAs with different periods are often combined: the short one crossing the long one marks a shift in momentum.
- Because old and new prices count equally, the SMA lags more than an EMA of the same period.
Using it in strategies
The SMA has one output, value (a price). In the Trade Setup you can use it with the rule "Price vs line", for example as a filter that allows longs only while the close is above the line, or with "Compare" against another moving average. In WickScript use the built-in sma(source, length), e.g. sma(close, 50), or load this indicator with use indicator "SMA" with period 50 as slow and read slow.value.
Settings
Open the settings with the slider icon next to the indicator (Indicators, F3). Numeric settings can be swept as Step 1 / Step 2 parameters when you run a strategy.
Inputs
| Setting | Type | Default | Description |
|---|---|---|---|
| Period | Number | 21 | Number of candles averaged (N). The average uses the close of each candle. (min 1) |
Styles
| Setting | Type | Default | Description |
|---|---|---|---|
| Line Color | Color | #88ff88 |
Outputs
These values can be used in Trade Setup triggers, filters and exits (see Trade Setup) and in WickScript.
| Output | In WickScript | Description |
|---|---|---|
| value | value |
Use in WickScript
use indicator creates this indicator inside a script, with settings by their ID. Each output is a field of the name after as. See WickScript indicators.
wickscript 1
indicator "Simple Moving Average (SMA) from the list" on chart
use indicator "SMA" with period 21 as mySma
show mySma.value as line "value"