The Money Flow Index (MFI) and Bollinger Bands are technical indicators that can be combined to identify price swings and trends:
MFI
A volume-weighted oscillator that measures price momentum and strength using price and volume data.
Bollinger Bands
A statistical chart that consists of a middle band and two outer bands that are calculated based on standard deviations from the middle band. The upper band is often considered resistance, the lower band is often considered support, and the middle band can act as either support or resistance depending on price.
Combining MFI and Bollinger Bands
Traders can use MFI and Bollinger Bands to identify when an asset's price might reverse, which can happen when the price touches the upper or lower Bollinger Band.
For example, John Bollinger's trading strategy uses %B, a technical indicator derived from Bollinger Bands, and MFI to identify the start of a new trend.
This study's approach differs from J.Bollinger's strategy, in that, it is averaging Money Flow Index and Bollinger Bands' %B
Colored bars indicate buy or sell signals
Per member @netarchitech request
https://usethinkscript.com/threads/...-pinescript-to-thinkscript.19442/#post-145266
original Tradingview script: https://www.tradingview.com/script/v6f40cDT-MFI-B-seiglerj/
see below for the ThinkOrSwim Study
MFI
A volume-weighted oscillator that measures price momentum and strength using price and volume data.
Bollinger Bands
A statistical chart that consists of a middle band and two outer bands that are calculated based on standard deviations from the middle band. The upper band is often considered resistance, the lower band is often considered support, and the middle band can act as either support or resistance depending on price.
Combining MFI and Bollinger Bands
Traders can use MFI and Bollinger Bands to identify when an asset's price might reverse, which can happen when the price touches the upper or lower Bollinger Band.
For example, John Bollinger's trading strategy uses %B, a technical indicator derived from Bollinger Bands, and MFI to identify the start of a new trend.
This study's approach differs from J.Bollinger's strategy, in that, it is averaging Money Flow Index and Bollinger Bands' %B
Colored bars indicate buy or sell signals

Per member @netarchitech request
https://usethinkscript.com/threads/...-pinescript-to-thinkscript.19442/#post-145266
original Tradingview script: https://www.tradingview.com/script/v6f40cDT-MFI-B-seiglerj/
see below for the ThinkOrSwim Study
CSS:
#// @author seiglerj
#// product of MFI and %B for reliable signals based on price, volatility, and volume
#study(title = "MFI & %B [seiglerj]", shorttitle="MFI & %B", precision=2)
declare lower;
input source = hlc3;
input mfilength = 14; #, title="MFI length", minval=1)
input bblength = 20; #, title="BB length", minval=1)
input bbstdevs = 2; #, title="BB std dev", minval=0, type=float)
input lower = 20; #, title="Lower Bound", minval=0, maxval=50, type=integer)
input upper = 80; #, title="Upper Bound", minval=50, maxval=100, type=integer)
input DrawMFI = yes; #(true, title="Draw MFI", type=bool)
input DrawBBP = yes; #(true, title="Draw %B", type=bool)
input DrawProd = yes; #t(true, title="Draw Product", type=bool)
input HighlightBreaches = yes; #, title="Highlight Breaches?", type=bool)
def na = Double.NaN;
def last = IsNaN(close);
#// MFI
def mf = MoneyFlowIndex(Length = mfilength);
def mfScaled = (mf - lower) / (upper - lower); # // inner band becomes 0-1 like B%
#// BB
def bbavg = Average(source, bblength);
def bbdev = bbstdevs * StDev(source, bblength);
def bbupper = bbavg + bbdev;
def bblower = bbavg - bbdev;
def bbp = (source - bblower) / (bbupper - bblower); # // usually 0-1, can exceed those bounds
#// combined
def both = (if mfScaled > 0.5 and bbp > 0.5 then Min(mfScaled, bbp) else
(if mfScaled < 0.5 and bbp < 0.5 then Max(mfScaled, bbp) else (mfScaled + bbp) / 2));
#// Draw MFI
plot mfp = if DrawMFI then mfScaled else na; #, title="MFI", color=color(yellow, 0), linewidth=1)
#// Draw %B
plot bbpp = if DrawBBP then bbp else na; #, title="%B", color=color(aqua, 0), linewidth=1)
#// Draw combined
plot bothPlot = if DrawProd then both else na; #, title="Average", color=color(black, 100), linewidth=1, editable=false)
mfp.SetDefaultColor(GetColor(4));
bbpp.SetDefaultColor(GetColor(1));
bothPlot.SetDefaultColor(GetColor(3));
#// Draw min chart bounds
def top = if last then na else 1; #, color=color(black,100), editable=false)
plot mid = if last then na else 0.5;
def bottom = if last then na else 0; #, color=color(black,100), editable=false)
mid.SetDefaultColor(Color.DARK_GRAY);
#// Breaches
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def b_color = if !HighlightBreaches then 0 else if both > 1 then -1 else if both < 0 then 1 else 0;
AddCloud(if (b_color>0 or b_color[1]>0) then pos else na, neg, Color.GREEN);
AddCloud(if (b_color<0 or b_color[1]<0) then pos else na, neg, Color.RED);
AddCloud(top, bottom, Color.DARK_GRAY);
# End of CODE
Last edited by a moderator: