Skip to main content

LSMA

Source​

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

Syntax Format​

lsma(period, offset, source)

Overview​

LSMA (Least Squares Moving Average) belongs to the MA family, and uses the linear regression to assume the further price movement of an asset. This type of Moving Average can be useful for identifying trends' direction and strength, as well as predicting further price movement of an asset.

Parameters​

ParameterTypePurpose
periodintegerMoving Average period
offsetintegerDeviation
sourceseriesInput series, taken into calculation

Example​

instrument { name = "LSMA", overlay = true }

period = input (25,"period", input.integer, 1, 200)
offset = input (0, "offset", input.integer, -100, 100)
source = input (1, "source", input.string_selection, inputs.titles_overlay)

input_group {
"LSMA Line",
color = input { default = rgba(86,206,255,0.75), type = input.color },
width = input { default = 1, type = input.line_width}
}

local sourceSeries = inputs [source]

plot (linreg (sourceSeries, period, offset), "LSMA", color, width)