#education purpose
# indie:lang_version = 4
from indie import indicator, plot, color, param, MutSeriesF, Plot
from indie.algorithms import Ema

@indicator("Elder's Force Index", overlay_main_pane=False)
@param.int('length', default=13, min=1, title="Length")
def Main(self, length):
    # Create a mutable series for the Force Index calculation
    fi_series = MutSeriesF.new((self.close[0] - self.close[1]) * self.volume[0])
    
    # Apply exponential moving average (EMA) to smooth the Force Index
    efi = Ema.new(fi_series, length)[0]
    
    # Return the plotted Force Index with a white color line
    return Plot(efi, color=color.WHITE)
