Fibonacci Moving Average (FMA)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262

//@version=5
indicator("Fibonacci Moving Average", "FMA", true)
metallic_mean(source)=>
    (source+math.sqrt(math.pow(source, 2) + 4))/2

mwma(source, length)=>
    float src = metallic_mean(source)
    var float weight_sum = na
    var float sum        = na
    for i = 0 to length - 1
        weight = metallic_mean(i)
        weight_sum := nz(weight_sum[1]) + weight
        sum := nz(sum[1]) + src * weight
    out = (sum - nz(sum[length]))/(weight_sum - nz(weight_sum[length]))

source = input.source(close, "Source")
length = input.int(20, "Length", 2) 


plot(mwma(source, length))
