The idea
This is OztheWoz's open-source strategy, published as "MFI Simple Strategy". The idea is short: a 200-period average tells you whether price is still on the long side of the market, and a smoothed money-flow index has to confirm that money is still pushing higher. It does not wait for an oversold cross to enter. It only asks whether the smoothed MFI has already risen for two bars in a row. The author's chart is BYBIT:BTCUSDT.P on the 30-minute, so this entry is filed under BTC. The script does not hard-code a symbol.
It is long-only; there is no mirrored short path. The pane plots the smoothed MFI with reference lines at 80 and 20, and it fills above 80 when the line is up there, but those levels are not used in the orders. overlay is false, so the script lands in a sub-pane when you add it to a chart.

How the lines are built
- Money flow is ta.mfi(close, len) with a default length of 18. The source series is close, not the more common typical price.
- That MFI is then smoothed with a simple moving average of the same length. Every comparison later in the script uses this smoothed line, not the raw MFI.
- The rise condition mfiup is current value above the previous bar, and the previous bar above the one before that: two successive rises.
- The turn-down condition mfidn is current value below the previous bar, while the previous bar is still above the one before it. It fires only after an up-step and then a drop, not on every decline.
- The directional filter is a 200-period simple moving average of close, named goldsma.
Entry rules
- Long only. The source never calls strategy.short.
- Close must be above the 200-period average, and mfiup must be true. Those checks are stacked: the average test is in an if, and mfiup is the when argument on the entry.
- The script does not require the smoothed MFI to be under 20 or to leave an oversold zone. The 20 and 80 lines are visual only.
Exits and position size
- A strategy.exit is placed with the stop at the current 200-period average. Because that average moves, the stop moves with it; it is not a fixed price.
- When mfidn is true, strategy.close also flattens the long at market. So a turn down in the smoothed MFI after a rise can exit before price hits the average.
- The source does not set order size, initial capital, or commission, so the tester uses TradingView's strategy defaults. Live routing has to be set separately.
Inputs (defaults in the source)
| Input | Default | What it does |
|---|---|---|
| Length | 18 | Lookback for the money-flow index, and for the average that smooths it. |
| 200-period average | Hard-coded as 200, not an input | Close must be above it to enter, and the stop is also placed on this line. |
Caveats
- The strategy never goes short. If price drops below the 200-period average it will not open a short, and an open long may be stopped out on that average.
- mfidn needs a prior up-step before the turn down. A run of falling smoothed-MFI bars will not keep retriggering that market exit.
- The 20 and 80 lines are not part of the order logic. Do not treat them as oversold or overbought entry rules.
- The author's chart is a Bybit BTCUSDT perpetual, 30-minute. Spot or another venue will not share the same volume, so money flow will differ.
- The strategy.exit id is also "Long", the same as the entry name. That is how the source is written; keep it in mind when you read tester logs.
Install it on TradingView
- Download the .pine file from Coinpred (a current membership is required; see the page) or check the original publication for a newer revision.
- Open the symbol and timeframe you want in TradingView, open the Pine Editor, paste the source, and add it to the chart.
- Start with the default length of 18 and the hard-coded 200-period average so you can see the entries and exits, then change the length for your market and timeframe. Editing the 200-period average means editing the source.
- The source does not specify order size, capital, or commission, so the tester uses platform defaults. Live order routing has to be set separately.
- Crypto trades around the clock. The tester's timezone and session settings may differ from your venue by several hours.
About backtest figures
Source, license, and version
- Source: https://www.tradingview.com/script/AKXK9Jub-MFI-Simple-Strategy/
- Author: OztheWoz (header © OztheWoz)
- License: Mozilla Public License 2.0. Redistribution must keep the original copyright and license notices; if you modify the source file, the modified file must remain under MPL 2.0. Coinpred ships the unmodified source.
- Version: 1.0 in the publication record and pine-facade. scriptAccess is open_no_auth.



