NEWCard payments are live · from $18/month, USDT also acceptedSee plans
COINPRED / STRATEGY LIBRARY

BTC simple MFI: Go long when close is above the 200 SMA and smoothed MFI has risen for two bars; exit when that line turns down after a rise, with the 200 SMA as a stop

OztheWoz's open-source trend script (MPL 2.0), titled "MFI Simple Strategy". It calculates money flow from close, then smooths that MFI with a simple average of the same length. A long needs close above the 200-period average and two successive rises in the smoothed MFI. It exits when that line turns down after a rise, and it also keeps a stop on the 200-period average. Long only. The author's chart is BYBIT:BTCUSDT.P, 30-minute. Rules follow the source; this page invents no backtest figures.

Illustrated guidesPine Script®Included with monthly & annual plans
← All strategies
OztheWoz · 1.0 · 2026-12-03 · Trend following
BTC simple MFI: Go long when close is above the 200 SMA and smoothed MFI has risen for two bars; exit when that line turns down after a rise, with the 200 SMA as a stop

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.

Author chart of OztheWoz MFI Simple Strategy on BYBIT:BTCUSDT.P 30-minute
Author chart: BYBIT:BTCUSDT.P, 30-minute, from the script's publication page. The image shows the smoothed money-flow line, the reference levels, and trade markers. It is only an illustration, not a live or backtest track record.

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)

InputDefaultWhat it does
Length18Lookback for the money-flow index, and for the average that smooths it.
200-period averageHard-coded as 200, not an inputClose 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

  1. Download the .pine file from Coinpred (a current membership is required; see the page) or check the original publication for a newer revision.
  2. Open the symbol and timeframe you want in TradingView, open the Pine Editor, paste the source, and add it to the chart.
  3. 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.
  4. The source does not specify order size, capital, or commission, so the tester uses platform defaults. Live order routing has to be set separately.
  5. 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.

Source, license and version

Licensed under MPL 2.0 per the source header, © OztheWoz. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified source.

View original source ↗

Check the script license and your TradingView account features. Historical results do not guarantee future performance.

Related strategies

All strategies →