Strategy
This strategy is backtested on daily OHLCV price data across major US equity indices and ETFs. Entry and exit signals are generated from the strategy's indicators with no lookahead bias — trades execute at the open of the bar following the signal.
Performance metrics are computed per symbol and shown individually. The parameter optimization section (where available) runs a grid search over the strategy's key parameters, optimizing for Sharpe ratio. Transaction costs and slippage are not modeled.
The signal logic and indicator code for this strategy is shown in the methodology code section below.
Money Flow Index is a volume-weighted RSI. Enters long when MFI drops below 20 (oversold with volume confirmation), exits when MFI rises above 80. Volume weighting makes it more reliable than price-only oscillators.
class MoneyFlowIndex(Strategy):
n = 14
def init(self):
self.mfi = self.I(_mfi, self.data.High, self.data.Low, self.data.Close, self.data.Volume, self.n)
def next(self):
if self.mfi[-1] < 20 and not self.position: self.buy()
elif self.mfi[-1] > 80 and self.position: self.position.close()| Total return | +112.332% |
| Net profit | $1,123,324 |
| Gross profit | $579,227 |
| Gross loss | $298,890 |
| CAGR | +7.013% |
| Annualized return | +7.013% |
| Monthly average return | +0.519% |
| Median monthly return | +1.420% |
| Best month return | +8.062% |
| Worst month return | -4.477% |
| Rolling 1-month return | +13.306% |
| Return per trade | +3.442 |
| Log return CAGR | +27.945% |
| Compounded vs simple return difference | -100.259% |
2 trades · green dashes = buy entries · red dashes = sell exits
| Total return | +4.087% |
| Net profit | $40,870 |
| Gross profit | $97,900 |
| Gross loss | $51,950 |
| CAGR | +1.212% |
| Annualized return | +1.212% |
| Monthly average return | +0.105% |
| Median monthly return | +0.000% |
| Best month return | +5.343% |
| Worst month return | +0.000% |
| Rolling 1-month return | +10.698% |
| Return per trade | +2.023 |
| Log return CAGR | +5.231% |
| Compounded vs simple return difference | +0.000% |