Simply put, Force Index by Alexander Elder is an EMA of a "raw" Force Index, which is:
# raw force index
RFI = Volume * (Close - Prev Close)
To initialize the EMA of RFI, you'd need to do a basic Simple Moving Average (SMA) of the first Period
bars of the daily
RFI. Without this initialization, you're essentially using 0
as the initialization, which is not terrible, but it might take an extra 100-200 bars before it converges to acceptable accuracy due to the way EMA works.
# EMA of RFI
# For the first instance, substitute SMA of RFI for Previous Force Index (not shown)
k = 2 / (Period + 1)
ForceIndex = Prev Force Index + k * (RFI - Previous Force Index)
Other than that, fromFrom what I can tell, your final formula appears mostlyto be correct. My open-source C# .NET library includes the formula for Force Index and a manually calculated Excel spreadsheet. Might be worth a comparison.