[pshaiScript] Arnaud Legoux Moving Average

1 33 Views No Comments 2 weeks ago
  • The ALMA indicator function.

    HaasScript Code
    function alma(series, windowsize, offset, sigma)
        local length = windowsize
        local m = Floor(offset * (length - 1))
        local s = length / sigma
        local norm = 0.0
        local sum = 0.0
        local weight
    
        for i = length, 1, -1 do
            weight = Exp(-1 * Pow(i - m, 2) / (2 * Pow(s, 2)))
            norm = norm + weight
            sum = sum + series[length - (i - 1)] * weight
        end
    
        return sum / norm
    end
    
    -- usage
    local c = ClosePrices()
    Plot(0, 'ALMA', alma(c, 9, 0.5, 6))
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free