MoneyFlowIndex — Money Flow Index
תוכן זה אינו זמין עדיין בשפה שלך.
The volume-weighted RSI: typical-price money flow split into positive and negative streams over the window, scaled 0–100. Extremes mean the same as RSI’s, but backed by traded money rather than price alone.
Signature
MoneyFlowIndex(period, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
period |
int Param or literal | Yes | Window. Default 14, bounds 1–400. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads high, low, close, volume. |
Formula
$$ TP = \tfrac{H+L+C}{3}, \quad RMF = TP \cdot V $$ $$ \text{MFI} = 100 - \frac{100}{1 + \sum RMF^{+} / \sum RMF^{-}} $$
Flows are positive on a bar whose typical price rose, negative when it fell. All-positive flow reads 100, all-negative 0, a fully flat window 50.
Warmup
period + 1 bars; 50 until then.
Reading the value
mfi.valuemfi < 20mfi.crossed_above(50)Example
class MfiReversion(Strategy): """Buy an MFI washout, exit at the midline.""" period = Param(14, min=1, max=400) trade = Symbol() sizing = FixedCapital()
def execute(self): mfi = MoneyFlowIndex(self.period, on=self.trade) if mfi.value < 20 and self.trade.is_flat: self.buy(self.trade, reason=f"MFI {mfi.value:.0f}") if mfi.value > 50 and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="MFI recovered")Notes
- Gene Quong & Avrum Soudack’s construction.
- Division-free edge handling: all-positive flow returns 100 directly rather than dividing.