Skip to content

Money Flow Index

MFI measures buying and selling pressure by considering both price and volume.

Method

tm.ta.mfi(source_high, source_low, source_close, source_volume, timeperiod)

Inputs

ParameterArgument typeDescriptionDefault Value
source_highpd.SeriesHigh prices series-
source_lowpd.SeriesLow prices series-
source_closepd.SeriesClose prices series-
source_volumepd.SeriesVolume series-
timeperiodintNumber of periods for the indicator14

Outputs

OutputType
mfinp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out Money Flow Index
mfi = tm.ta.mfi(data.high, data.low, data.close, data.volume, timeperiod=14)
# Get the last value and print
last_value = mfi.iloc[-1]
tm.log(f"Last value of Money Flow Index is {last_value}")
# Plot the values of mfi
tm.plot(mfi, title="Money Flow Index", overlay=False)