Interpolated SMA (ISMA)
// 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("Interpolated SMA", "ISMA", overlay = true)

import Electrified/Interpolation/1 as i

sma(source, length)=>
    var float sum = na
    sum := nz(sum[1]) + close
    if length % 1 != 0
        sma = (sum -  sum[int(length)] + (i.linear(length % 1, sum[int(length)] - sum[int(length)+1], 0, false)))/length
    else
        sma = (sum - sum[length])/length

source = input.source(close, "Source")
length = input.float(20.25, "Length", 1, 2000, 0.25)

plot(sma(source, length))
