ALMA
Source
https://github.com/quadcode-tech/quadcodescript-library/blob/master/averages/alma.lua
Syntax Format
alma(series, period, offset, sigma)
Overview
ALMA
(Arnaud Legoux Moving Average) belongs to the MA family, and it will help you indicate the asset price movement, smoothing the noise along the way and being more responsive to recent price changes.
Parameters
Parameter | Type | Purpose |
---|---|---|
period | integer | Moving Average Period, must be a positive integer number |
offset | numeric | Gaussian Distribution mean value. Controls responsiveness of the filter, where 0 is the least responsive and 1 is the most responsive |
sigma | numeric | Gaussian Distribution standard deviation. Controls the smoothness of the filter |
series | series | Input series, meaning the price values sequence taken into calculation |
Returns: series
.
Example
instrument { name = "ALMA", overlay = true }
period = input (9, "Period", input.integer, 1, 100 )
offset = input (0.85, "Offset", input.double, 0, 100, 0.01)
sigma = input (6, "ALMA Sigma", input.double, 0.01, 10, 1)
input_group {
"ALMA Line",
color = input { default = "#56CEFF", type = input.color },
width = input { default = 1, type = input.line_width}
}
Formula
The formula for calculating ALMA
is:
The ALMA
function is calculated by taking the sum of the weighted price values of an asset. The assigned weight is based on the Gaussian distribution, making the function more efficient for more short-term price movements. Next step in the calculation – make a sum of the weights, used for the price values within a chosen period, to balance the formula and make the result more objective.