Strategy vault / Mean reversion
Trading Strategy Based on Market Facilitation Index
This strategy uses the Market Facilitation Index (MFI) to judge the market's trending condition and possibility of trend reversal. It generates trading signals by calculating the relationship between price range and…
Overview
This strategy uses the Market Facilitation Index (MFI) to judge the market's trending condition and possibility of trend reversal. It generates trading signals by calculating the relationship between price range and volume to evaluate the efficiency of price movement.
Strategy Logic
Calculate MFI, formula: (Highest - Lowest) / Volume * 10000
Set buy and sell thresholds, such as buy when MFI > 1 and sell when MFI < 0.8
Go long when MFI crosses above buy threshold, go short when crossing below sell threshold
Color code bars based on signals for visual representation
Option to reverse signal directions
Advantage Analysis
Strong ability to evaluate market trending and price movement efficiency
Simple parameter setup, easy to determine thresholds
Clear trading signals, easy to interpret and execute
Visual bar colors intuitively display market conditions
Flexibility to go long or short as needed
Risk Analysis
Unable to determine trend strength, risks insufficient profit
Cannot differentiate normal fluctuations or real reversals
Prone to false signals from sudden events
Has some lag, may miss best entry points
No stop loss mechanism, unable to control single loss
Optimization Directions
Test different parameter threshold values
Add volume-price indicators for confirmation
Incorporate moving averages to determine trend direction
Establish stop loss strategies for risk control
Define position sizing rules to adjust with markets
Test performance in live markets across different instruments and timeframes
Summary
This strategy uses MFI to judge market trending conditions and provide simple trade signals. Further improvements in parameter optimization, stop losses etc. are needed for strict risk control. But the logic is clear and feasible to serve as part of a trend following strategy, thus having practical value.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 6.2 | SellZone |
| v_input_2 | true | BuyZone |
| v_input_3 | false | Trade reverse |
Source Pine Script
/*backtest
start: 2023-08-19 00:00:00
end: 2023-09-18 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 12/09/2018
// The Market Facilitation Index is an indicator that relates price range to
// volume and measures the efficency of price movement. Use the indicator to
// determine if the market is trending. If the Market Facilitation Index increased,
// then the market is facilitating trade and is more efficient, implying that the
// market is trending. If the Market Facilitation Index decreased, then the market
// is becoming less efficient, which may indicate a trading range is developing that
// may be a trend reversal.
//
// You can change long to short in the Input Settings
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Market Facilitation Index (MFI) Backtest", shorttitle="MFI")
SellZone = input(6.2, minval=0.01, step = 0.01)
BuyZone = input(1, minval=0.01, step = 0.01)
reverse = input(false, title="Trade reverse")
hline(BuyZone, color=green, linestyle=line)
hline(SellZone, color=red, linestyle=line)
xmyVol = volume
xmyhigh = high
xmylow = low
nRes = (xmyhigh - xmylow) / xmyVol * 10000
pos = iff(nRes > BuyZone, 1,
iff(nRes < SellZone, -1, nz(pos[1], 0)))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1, 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(nRes, color=green, title="MFI", style = histogram)Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-19. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Trading-Strategy-Based-on-Market-Facilitation-Index.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- 1 2 3 Pattern Quantitative Trading Strategy with EMAs MACD and 4th Candle ExtensionPine Script · Mean reversion · 1h
- 3 10 Oscillator Profile Flagging StrategyPine Script · Mean reversion · 1d
- A Trend Reversal Strategy Based on Moving Averages Price Patterns and VolumePine Script · Mean reversion · 1d
- ATR and EMA based Dynamic Take Profit and Stop Loss Adaptive StrategyPine Script · Mean reversion · 1h
- Adaptive Mean Reversion Trading Strategy Based on Chande Momentum OscillatorPine Script · Mean reversion · 1d
- Adaptive Moving Average Tracking StrategyPine Script · Mean reversion · 1d