Skip to main content

SSMA

Source

https://github.com/quadcode-tech/quadcodescript-library/blob/master/averages/ma_ssma.lua

Syntax Format

ssma(series, period)

Overview

SSMA (Smoothed Simple Moving Average) smoothes the price data, providing the averaged price value for the chosen timeframe. The main difference from the Simple Moving Average (SMA) is that older price data is given more weight to smooth the price movements and highlight more prominent trends, as well as decrease noise from the analysis.

Parameters

ParameterTypePurpose
sourceseriesInput series, taken into calculation
periodnumericMoving Average period

Returns*: series.

*If there are less than period values in the series – the result is nan

Example

instrument { name = "Smoothed Simple Moving Average", short_name = "SSMA", overlay = true, icon="indicators:MA" }

period = input (7, "period", input.integer, 1)
source = input (1, "source", input.string_selection, inputs.titles_overlay)

input_group {
"SSMA Line",
color = input { default = "#DB4931", type = input.color },
width = input { default = 1, type = input.line_width}
}

local sourceSeries = inputs [source]

plot (ssma (sourceSeries, period), "SSMA", color, width)

Formula

The formula for calculating SSMA is:

image.png

The first value of SSMA is calculated as SMA: sma(series, period). For subsequent values of the SSMA the price values are taken, added to the current price value and divided by the chosen period.