Bill Williams Volume and MFI For ThinkOrSwim

Igor

New member
VIP
Can anyone convert this TradingView indicator for ThinkOrSwim. Thank you!!!

study(title="Bill Williams Volume and MFI notation [tekolo]", shorttitle="BW ProfitUnity", overlay=true)

// The Bill Williams Profitunity provides a unique way of quantifying price movement relative to volume.
// At the heart of it is the Market Facilatation Index (MFI). The MFI is the bar's range (high - low)
// divided by the volume. Using the MFI, each bar has a mathematical relationship of the price activity
// versus the volume. In essence, the MFI is a measurement of market efficiency, tracking how much
// movement has occurred in price relative to volume. By comparing the MFI for the current bar to the
// previous bar's, you can gauge the current bar's ability to facilitate price to the previous bar's
// ability. The Bill Williams Profitunity can be used on any period from daily bars to monthly bars.
//
// The MFI as a stand-alone indicator has little value. However, by comparing the current bar's MFI and
// volume with the previous bar's MFI and volume, a very tradable system emerges.

// Williams defines the four possible combinations of MFI and volume as follows. A plus sign means the
// current bar's value is greater than the previous bar's value. A minus sign means the current bar's
// value is less than the previous bar's value.

// Volume MFI Label:
// Green
// Fade
// Fake
// Squat

// Green. This bar shows an increase in volume and the MFI relative to the previous bar. Hence, there is
// price movement, and the MFI is larger for this bar than that for the previous bar. Further, more
// players are entering the market as signaled by the increase in volume. This activity in the futures
// market means that off-floor traders are very active. In addition, the price action is directional
// that is, the market is moving in one direction due to the involvement of new traders putting on new
// positions. This is the kind of day that you would already want to have a trade on in the same direction.

// Fade. This bar shows a decrease in volume and the MFI relative to the previous bar. The market has slowed
// and there is a minor amount of activity as indicated by the low volume. This type of day is called a fade,
// as the traders' interest in the market by this point is fading. Often, this sort of day happens at the end
// of a trend. The market has simply reached a point where nobody is willing to establish any new positions.
// At this point the market appears to be suffering from a certain amount of boredom. Keep in mind, however,
// that out of this market condition, a new trend could emerge.

// Fake. This bar shows a decrease in volume but an increase in the MFI. This condition means that the market
// is moving more relative to the previous bar (the greater MFI), but the lack of volume is evidence that there
// is no new participation. The price action may be driven by just the traders in the pit and is not attracting
// new players from the outside. Williams has an hypothesis, that the traders in the pit may be just strong enough
// to push the market to price levels where there are many stop orders resting in the hands of the brokers, hence
// faking out the off-floor traders.

// Squat. This bar shows an increase in volume relative to the previous bar, but the MFI is lower. The increase
// in volume indicates heavy activity, but the decrease in the MFI indicates that the market is unable to make
// any real headway. Volume increased, the trend has stalled and the price movement has stopped. This price action
// usually, but not always occurs prior to an important move in the opposite direction. This type of bar is called
// a squat bar because the market appears to be squatting prior to a breakout. Often, the breakout of such a bar will
//indicate whether this squat is a trend reversal squat or a trend continuation squat.

// More info:
// http://analyzerxl.com/webhelp/BulkQuotesXL Pro Online Help/scr/HTMLs/TA_Library/BillWilliamsProfitunity.htm
// https://en.wikipedia.org/wiki/Market_facilitation_index
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

It's not what I'd call pretty:

Code:
def MFI0 = (high - low) / volume;
def MFI1 = (high[1] - low[1]) / volume[1];

def MFIplus = MFI0 > MFI1;
def MFIminus = MFI0 < MFI1;

def meanplus = hl2 > high[1];
def meanminus = hl2 < high[1];

def volplus = volume > volume[1];
def volminus = volume < volume[1];

def b13 = open < hl2 and close > hl2 and close > open;
def b31 = open > hl2 and close < hl2 and close < open;

def plusb13plusplus = meanplus and b13 and volplus and MFIplus;
AddChartBubble(plusb13plusplus, low, text="+13++\nGreen", color.green, yes);

def plusb13minusminus = meanplus and b13 and volminus and MFIminus;
AddChartBubble(plusb13minusminus, low, text="+13--\nfade", color.blue, yes);

def plusb13minusplus = meanplus and b13 and volminus and MFIplus;
AddChartBubble(plusb13minusplus, low, text="+13-+\nfake", color.dark_red, yes);

def plusb13plusminus = meanplus and b13 and volplus and MFIminus;
AddChartBubble(plusb13plusminus, low, text="+13+-\nsquat", color.pink, yes);

def minusb13plusplus = meanminus and b13 and volplus and MFIplus;
AddChartBubble(minusb13plusplus, low, text="-13++", color.green, yes);

def minusb13minusminus = meanminus and b13 and volminus and MFIminus;
AddChartBubble(minusb13minusminus, low, text="-13--", color.blue, yes);

def minusb13minusplus = meanminus and b13 and volminus and MFIplus;
AddChartBubble(minusb13minusplus, low, text="-13-+", color.dark_red, yes);

def minusb13plusminus = meanminus and b13 and volplus and MFIminus;
AddChartBubble(minusb13plusminus, low, text="-13+-", color.pink, yes);

def plusb31plusplus = meanplus and b31 and volplus and MFIplus;
AddChartBubble(plusb31plusplus, low, text="+31++", color.green, yes);

def plusb31minusminus = meanplus and b31 and volminus and MFIminus;
AddChartBubble(plusb31minusminus, low, text="+31--", color.blue, yes);

def plusb31minusplus = meanplus and b31 and volminus and MFIplus;
AddChartBubble(plusb31minusplus, low, text="+b31-+", color.dark_red, yes);

def plusb31plusminus = meanplus and b31 and volplus and MFIminus;
AddChartBubble(plusb31plusminus, low, text="+31+-", color.pink, yes);

def minusb31plusplus = meanminus and b31 and volplus and MFIplus;
AddChartBubble(minusb31plusplus, low, text="-31++\nGreen", color.green, yes);

def minusb31minusminus = meanminus and b31 and volminus and MFIminus;
AddChartBubble(minusb31minusminus, low, text="-31--\nfade", color.blue, yes);

def minusb31minusplus = meanminus and b31 and volminus and MFIplus;
AddChartBubble(minusb31minusplus, low, text="-31-+\nfake", color.dark_red, yes);

def minusb31plusminus = meanminus and b31 and volplus and MFIminus;
AddChartBubble(minusb31plusminus, low, text="-31+-\nsquat", color.pink, yes);

def plus23 = open > hl2 and close > hl2 and close > open;
AddChartBubble(plus23, low, text="23", color.gray, yes);

def plus12 = open < hl2 and close < hl2 and close > open;
AddChartBubble(plus12, low, text="12", color.gray, yes);

def plus21 = open < hl2 and close < hl2 and close < open;
AddChartBubble(plus21, low, text="21", color.gray, yes);

def plus32 = open > hl2 and close > hl2 and close < open;
AddChartBubble(plus32, low, text="32", color.gray, yes);

-mashume
 
It's not what I'd call pretty:

Code:
def MFI0 = (high - low) / volume;
def MFI1 = (high[1] - low[1]) / volume[1];

def MFIplus = MFI0 > MFI1;
def MFIminus = MFI0 < MFI1;

def meanplus = hl2 > high[1];
def meanminus = hl2 < high[1];

def volplus = volume > volume[1];
def volminus = volume < volume[1];

def b13 = open < hl2 and close > hl2 and close > open;
def b31 = open > hl2 and close < hl2 and close < open;

def plusb13plusplus = meanplus and b13 and volplus and MFIplus;
AddChartBubble(plusb13plusplus, low, text="+13++\nGreen", color.green, yes);

def plusb13minusminus = meanplus and b13 and volminus and MFIminus;
AddChartBubble(plusb13minusminus, low, text="+13--\nfade", color.blue, yes);

def plusb13minusplus = meanplus and b13 and volminus and MFIplus;
AddChartBubble(plusb13minusplus, low, text="+13-+\nfake", color.dark_red, yes);

def plusb13plusminus = meanplus and b13 and volplus and MFIminus;
AddChartBubble(plusb13plusminus, low, text="+13+-\nsquat", color.pink, yes);

def minusb13plusplus = meanminus and b13 and volplus and MFIplus;
AddChartBubble(minusb13plusplus, low, text="-13++", color.green, yes);

def minusb13minusminus = meanminus and b13 and volminus and MFIminus;
AddChartBubble(minusb13minusminus, low, text="-13--", color.blue, yes);

def minusb13minusplus = meanminus and b13 and volminus and MFIplus;
AddChartBubble(minusb13minusplus, low, text="-13-+", color.dark_red, yes);

def minusb13plusminus = meanminus and b13 and volplus and MFIminus;
AddChartBubble(minusb13plusminus, low, text="-13+-", color.pink, yes);

def plusb31plusplus = meanplus and b31 and volplus and MFIplus;
AddChartBubble(plusb31plusplus, low, text="+31++", color.green, yes);

def plusb31minusminus = meanplus and b31 and volminus and MFIminus;
AddChartBubble(plusb31minusminus, low, text="+31--", color.blue, yes);

def plusb31minusplus = meanplus and b31 and volminus and MFIplus;
AddChartBubble(plusb31minusplus, low, text="+b31-+", color.dark_red, yes);

def plusb31plusminus = meanplus and b31 and volplus and MFIminus;
AddChartBubble(plusb31plusminus, low, text="+31+-", color.pink, yes);

def minusb31plusplus = meanminus and b31 and volplus and MFIplus;
AddChartBubble(minusb31plusplus, low, text="-31++\nGreen", color.green, yes);

def minusb31minusminus = meanminus and b31 and volminus and MFIminus;
AddChartBubble(minusb31minusminus, low, text="-31--\nfade", color.blue, yes);

def minusb31minusplus = meanminus and b31 and volminus and MFIplus;
AddChartBubble(minusb31minusplus, low, text="-31-+\nfake", color.dark_red, yes);

def minusb31plusminus = meanminus and b31 and volplus and MFIminus;
AddChartBubble(minusb31plusminus, low, text="-31+-\nsquat", color.pink, yes);

def plus23 = open > hl2 and close > hl2 and close > open;
AddChartBubble(plus23, low, text="23", color.gray, yes);

def plus12 = open < hl2 and close < hl2 and close > open;
AddChartBubble(plus12, low, text="12", color.gray, yes);

def plus21 = open < hl2 and close < hl2 and close < open;
AddChartBubble(plus21, low, text="21", color.gray, yes);

def plus32 = open > hl2 and close > hl2 and close < open;
AddChartBubble(plus32, low, text="32", color.gray, yes);

-mashume
Thank you so much!!!

I was wondering if you can help me to plot on left top screen all the notifications instead on each candle. Thank you !!!
 
Thank you so much!!!

I was wondering if you can help me to plot on left top screen all the notifications instead on each candle. Thank you !!!
Ruby:
def MFI0 = (high - low) / volume;
def MFI1 = (high[1] - low[1]) / volume[1];

def MFIplus = MFI0 > MFI1;
def MFIminus = MFI0 < MFI1;

def meanplus = hl2 > high[1];
def meanminus = hl2 < high[1];

def volplus = volume > volume[1];
def volminus = volume < volume[1];

def b13 = open < hl2 and close > hl2 and close > open;
def b31 = open > hl2 and close < hl2 and close < open;


def plusb13plusplus = meanplus and b13 and volplus and MFIplus;
AddLabel(plusb13plusplus, "+13++\nGreen", color.green);

def plusb13minusminus = meanplus and b13 and volminus and MFIminus;
AddLabel(plusb13minusminus, "+13--\nfade", color.blue);

def plusb13minusplus = meanplus and b13 and volminus and MFIplus;
AddLabel(plusb13minusplus, "+13-+\nfake", color.dark_red);

def plusb13plusminus = meanplus and b13 and volplus and MFIminus;
AddLabel(plusb13plusminus, "+13+-\nsquat", color.pink);

def minusb13plusplus = meanminus and b13 and volplus and MFIplus;
AddLabel(minusb13plusplus, "-13++", color.green);

def minusb13minusminus = meanminus and b13 and volminus and MFIminus;
AddLabel(minusb13minusminus, "-13--", color.blue);

def minusb13minusplus = meanminus and b13 and volminus and MFIplus;
AddLabel(minusb13minusplus, "-13-+", color.dark_red);

def minusb13plusminus = meanminus and b13 and volplus and MFIminus;
AddLabel(minusb13plusminus, "-13+-", color.pink);

def plusb31plusplus = meanplus and b31 and volplus and MFIplus;
AddLabel(plusb31plusplus, "+31++", color.green);

def plusb31minusminus = meanplus and b31 and volminus and MFIminus;
AddLabel(plusb31minusminus, "+31--", color.blue);

def plusb31minusplus = meanplus and b31 and volminus and MFIplus;
AddLabel(plusb31minusplus, "+b31-+", color.dark_red);

def plusb31plusminus = meanplus and b31 and volplus and MFIminus;
AddLabel(plusb31plusminus, "+31+-", color.pink);

def minusb31plusplus = meanminus and b31 and volplus and MFIplus;
AddLabel(minusb31plusplus, "-31++\nGreen", color.green);

def minusb31minusminus = meanminus and b31 and volminus and MFIminus;
AddLabel(minusb31minusminus, "-31--\nfade", color.blue);

def minusb31minusplus = meanminus and b31 and volminus and MFIplus;
AddLabel(minusb31minusplus, "-31-+\nfake", color.dark_red);

def minusb31plusminus = meanminus and b31 and volplus and MFIminus;
AddLabel(minusb31plusminus, "-31+-\nsquat", color.pink);

def plus23 = open > hl2 and close > hl2 and close > open;
AddLabel(plus23, "23", color.gray);

def plus12 = open < hl2 and close < hl2 and close > open;
AddLabel(plus12, "12", color.gray);

def plus21 = open < hl2 and close < hl2 and close < open;
AddLabel(plus21, "21", color.gray);

def plus32 = open > hl2 and close > hl2 and close < open;
AddLabel(plus32, "32", color.gray);
 
Good evening team, It's possible to make the script above to save the previous candle notification and show in same time current candle?


I was trying to explain that the script it shows current candle if its fake or green and so on, I was looking if its possible to add the previous candle notification as well. Thank you !!!!
 
Last edited by a moderator:
This is UNTESTED. I did it in a text editor (everything may be broken) with a good search/replace functionality:
It replaces ALL of the addLabel() calls above, so that there are C: for current bar and P: for previous bar labels.
Code:
########### CURRENT BAR
def plusb13plusplus = meanplus and b13 and volplus and MFIplus;
AddLabel(plusb13plusplus, "C: +13++\nGreen", color.green);

def plusb13minusminus = meanplus and b13 and volminus and MFIminus;
AddLabel(plusb13minusminus, "C: +13--\nfade", color.blue);

def plusb13minusplus = meanplus and b13 and volminus and MFIplus;
AddLabel(plusb13minusplus, "C: +13-+\nfake", color.dark_red);

def plusb13plusminus = meanplus and b13 and volplus and MFIminus;
AddLabel(plusb13plusminus, "C: +13+-\nsquat", color.pink);

def minusb13plusplus = meanminus and b13 and volplus and MFIplus;
AddLabel(minusb13plusplus, "C: -13++", color.green);

def minusb13minusminus = meanminus and b13 and volminus and MFIminus;
AddLabel(minusb13minusminus, "C: -13--", color.blue);

def minusb13minusplus = meanminus and b13 and volminus and MFIplus;
AddLabel(minusb13minusplus, "C: -13-+", color.dark_red);

def minusb13plusminus = meanminus and b13 and volplus and MFIminus;
AddLabel(minusb13plusminus, "C: -13+-", color.pink);

def plusb31plusplus = meanplus and b31 and volplus and MFIplus;
AddLabel(plusb31plusplus, "C: +31++", color.green);

def plusb31minusminus = meanplus and b31 and volminus and MFIminus;
AddLabel(plusb31minusminus, "C: +31--", color.blue);

def plusb31minusplus = meanplus and b31 and volminus and MFIplus;
AddLabel(plusb31minusplus, "C: +b31-+", color.dark_red);

def plusb31plusminus = meanplus and b31 and volplus and MFIminus;
AddLabel(plusb31plusminus, "C: +31+-", color.pink);

def minusb31plusplus = meanminus and b31 and volplus and MFIplus;
AddLabel(minusb31plusplus, "C: -31++\nGreen", color.green);

def minusb31minusminus = meanminus and b31 and volminus and MFIminus;
AddLabel(minusb31minusminus, "C: -31--\nfade", color.blue);

def minusb31minusplus = meanminus and b31 and volminus and MFIplus;
AddLabel(minusb31minusplus, "C: -31-+\nfake", color.dark_red);

def minusb31plusminus = meanminus and b31 and volplus and MFIminus;
AddLabel(minusb31plusminus, "C: -31+-\nsquat", color.pink);

def plus23 = open > hl2 and close > hl2 and close > open;
AddLabel(plus23, "C: 23", color.gray);

def plus12 = open < hl2 and close < hl2 and close > open;
AddLabel(plus12, "C: 12", color.gray);

def plus21 = open < hl2 and close < hl2 and close < open;
AddLabel(plus21, "C: 21", color.gray);

def plus32 = open > hl2 and close > hl2 and close < open;
AddLabel(plus32, "C: 32", color.gray);

################# PERVIOUS BAR

AddLabel(plusb13plusplus[1], "P: +13++\nGreen", color.green);

AddLabel(plusb13minusminus[1], "P: +13--\nfade", color.blue);

AddLabel(plusb13minusplus[1], "P: +13-+\nfake", color.dark_red);

AddLabel(plusb13plusminus[1], "P: +13+-\nsquat", color.pink);

AddLabel(minusb13plusplus[1], "P: -13++", color.green);

AddLabel(minusb13minusminus[1], "P: -13--", color.blue);

AddLabel(minusb13minusplus[1], "P: -13-+", color.dark_red);

AddLabel(minusb13plusminus[1], "P: -13+-", color.pink);

AddLabel(plusb31plusplus[1], "P: +31++", color.green);

AddLabel(plusb31minusminus[1], "P: +31--", color.blue);

AddLabel(plusb31minusplus[1], "P: +b31-+", color.dark_red);

AddLabel(plusb31plusminus[1], "P: +31+-", color.pink);

AddLabel(minusb31plusplus[1], "P: -31++\nGreen", color.green);

AddLabel(minusb31minusminus[1], "P: -31--\nfade", color.blue);

AddLabel(minusb31minusplus[1], "P: -31-+\nfake", color.dark_red);

AddLabel(minusb31plusminus[1], "P: -31+-\nsquat", color.pink);

AddLabel(plus23[1], "P: 23", color.gray);

AddLabel(plus12[1], "P: 12", color.gray);

AddLabel(plus21[1], "P: 21", color.gray);

AddLabel(plus32[1], "P: 32", color.gray);
Thank you 🙏
 
This is UNTESTED. I did it in a text editor (everything may be broken) with a good search/replace functionality:
It replaces ALL of the addLabel() calls above, so that there are C: for current bar and P: for previous bar labels.
Code:
########### CURRENT BAR
def plusb13plusplus = meanplus and b13 and volplus and MFIplus;
AddLabel(plusb13plusplus, "C: +13++\nGreen", color.green);

def plusb13minusminus = meanplus and b13 and volminus and MFIminus;
AddLabel(plusb13minusminus, "C: +13--\nfade", color.blue);

def plusb13minusplus = meanplus and b13 and volminus and MFIplus;
AddLabel(plusb13minusplus, "C: +13-+\nfake", color.dark_red);

def plusb13plusminus = meanplus and b13 and volplus and MFIminus;
AddLabel(plusb13plusminus, "C: +13+-\nsquat", color.pink);

def minusb13plusplus = meanminus and b13 and volplus and MFIplus;
AddLabel(minusb13plusplus, "C: -13++", color.green);

def minusb13minusminus = meanminus and b13 and volminus and MFIminus;
AddLabel(minusb13minusminus, "C: -13--", color.blue);

def minusb13minusplus = meanminus and b13 and volminus and MFIplus;
AddLabel(minusb13minusplus, "C: -13-+", color.dark_red);

def minusb13plusminus = meanminus and b13 and volplus and MFIminus;
AddLabel(minusb13plusminus, "C: -13+-", color.pink);

def plusb31plusplus = meanplus and b31 and volplus and MFIplus;
AddLabel(plusb31plusplus, "C: +31++", color.green);

def plusb31minusminus = meanplus and b31 and volminus and MFIminus;
AddLabel(plusb31minusminus, "C: +31--", color.blue);

def plusb31minusplus = meanplus and b31 and volminus and MFIplus;
AddLabel(plusb31minusplus, "C: +b31-+", color.dark_red);

def plusb31plusminus = meanplus and b31 and volplus and MFIminus;
AddLabel(plusb31plusminus, "C: +31+-", color.pink);

def minusb31plusplus = meanminus and b31 and volplus and MFIplus;
AddLabel(minusb31plusplus, "C: -31++\nGreen", color.green);

def minusb31minusminus = meanminus and b31 and volminus and MFIminus;
AddLabel(minusb31minusminus, "C: -31--\nfade", color.blue);

def minusb31minusplus = meanminus and b31 and volminus and MFIplus;
AddLabel(minusb31minusplus, "C: -31-+\nfake", color.dark_red);

def minusb31plusminus = meanminus and b31 and volplus and MFIminus;
AddLabel(minusb31plusminus, "C: -31+-\nsquat", color.pink);

def plus23 = open > hl2 and close > hl2 and close > open;
AddLabel(plus23, "C: 23", color.gray);

def plus12 = open < hl2 and close < hl2 and close > open;
AddLabel(plus12, "C: 12", color.gray);

def plus21 = open < hl2 and close < hl2 and close < open;
AddLabel(plus21, "C: 21", color.gray);

def plus32 = open > hl2 and close > hl2 and close < open;
AddLabel(plus32, "C: 32", color.gray);

################# PERVIOUS BAR

AddLabel(plusb13plusplus[1], "P: +13++\nGreen", color.green);

AddLabel(plusb13minusminus[1], "P: +13--\nfade", color.blue);

AddLabel(plusb13minusplus[1], "P: +13-+\nfake", color.dark_red);

AddLabel(plusb13plusminus[1], "P: +13+-\nsquat", color.pink);

AddLabel(minusb13plusplus[1], "P: -13++", color.green);

AddLabel(minusb13minusminus[1], "P: -13--", color.blue);

AddLabel(minusb13minusplus[1], "P: -13-+", color.dark_red);

AddLabel(minusb13plusminus[1], "P: -13+-", color.pink);

AddLabel(plusb31plusplus[1], "P: +31++", color.green);

AddLabel(plusb31minusminus[1], "P: +31--", color.blue);

AddLabel(plusb31minusplus[1], "P: +b31-+", color.dark_red);

AddLabel(plusb31plusminus[1], "P: +31+-", color.pink);

AddLabel(minusb31plusplus[1], "P: -31++\nGreen", color.green);

AddLabel(minusb31minusminus[1], "P: -31--\nfade", color.blue);

AddLabel(minusb31minusplus[1], "P: -31-+\nfake", color.dark_red);

AddLabel(minusb31plusminus[1], "P: -31+-\nsquat", color.pink);

AddLabel(plus23[1], "P: 23", color.gray);

AddLabel(plus12[1], "P: 12", color.gray);

AddLabel(plus21[1], "P: 21", color.gray);

AddLabel(plus32[1], "P: 32", color.gray);
This doesn't seem to be working, any help here?

Can anyone help me create an indicator that Labels the Bill Williams MFI of the current bar and the previous bar? It should look something like the picture attached? I'm not looking for the candles to be painted but just the label of either squat, green, fade or fake of the previous and current candle in the top left corner of the chart. Thanks!
 
Last edited by a moderator:
@grandpa john Try the code below. I combined the one by @MerryDay and @mashume

Code:
def MFI0 = (high - low) / volume;
def MFI1 = (high[1] - low[1]) / volume[1];

def MFIplus = MFI0 > MFI1;
def MFIminus = MFI0 < MFI1;

def meanplus = hl2 > high[1];
def meanminus = hl2 < high[1];

def volplus = volume > volume[1];
def volminus = volume < volume[1];

def b13 = open < hl2 and close > hl2 and close > open;
def b31 = open > hl2 and close < hl2 and close < open;

########### CURRENT BAR
def plusb13plusplus = meanplus and b13 and volplus and MFIplus;
AddLabel(plusb13plusplus, "C: +13++\nGreen", color.green);

def plusb13minusminus = meanplus and b13 and volminus and MFIminus;
AddLabel(plusb13minusminus, "C: +13--\nfade", color.blue);

def plusb13minusplus = meanplus and b13 and volminus and MFIplus;
AddLabel(plusb13minusplus, "C: +13-+\nfake", color.dark_red);

def plusb13plusminus = meanplus and b13 and volplus and MFIminus;
AddLabel(plusb13plusminus, "C: +13+-\nsquat", color.pink);

def minusb13plusplus = meanminus and b13 and volplus and MFIplus;
AddLabel(minusb13plusplus, "C: -13++", color.green);

def minusb13minusminus = meanminus and b13 and volminus and MFIminus;
AddLabel(minusb13minusminus, "C: -13--", color.blue);

def minusb13minusplus = meanminus and b13 and volminus and MFIplus;
AddLabel(minusb13minusplus, "C: -13-+", color.dark_red);

def minusb13plusminus = meanminus and b13 and volplus and MFIminus;
AddLabel(minusb13plusminus, "C: -13+-", color.pink);

def plusb31plusplus = meanplus and b31 and volplus and MFIplus;
AddLabel(plusb31plusplus, "C: +31++", color.green);

def plusb31minusminus = meanplus and b31 and volminus and MFIminus;
AddLabel(plusb31minusminus, "C: +31--", color.blue);

def plusb31minusplus = meanplus and b31 and volminus and MFIplus;
AddLabel(plusb31minusplus, "C: +b31-+", color.dark_red);

def plusb31plusminus = meanplus and b31 and volplus and MFIminus;
AddLabel(plusb31plusminus, "C: +31+-", color.pink);

def minusb31plusplus = meanminus and b31 and volplus and MFIplus;
AddLabel(minusb31plusplus, "C: -31++\nGreen", color.green);

def minusb31minusminus = meanminus and b31 and volminus and MFIminus;
AddLabel(minusb31minusminus, "C: -31--\nfade", color.blue);

def minusb31minusplus = meanminus and b31 and volminus and MFIplus;
AddLabel(minusb31minusplus, "C: -31-+\nfake", color.dark_red);

def minusb31plusminus = meanminus and b31 and volplus and MFIminus;
AddLabel(minusb31plusminus, "C: -31+-\nsquat", color.pink);

def plus23 = open > hl2 and close > hl2 and close > open;
AddLabel(plus23, "C: 23", color.gray);

def plus12 = open < hl2 and close < hl2 and close > open;
AddLabel(plus12, "C: 12", color.gray);

def plus21 = open < hl2 and close < hl2 and close < open;
AddLabel(plus21, "C: 21", color.gray);

def plus32 = open > hl2 and close > hl2 and close < open;
AddLabel(plus32, "C: 32", color.gray);

################# PERVIOUS BAR

AddLabel(plusb13plusplus[1], "P: +13++\nGreen", color.green);

AddLabel(plusb13minusminus[1], "P: +13--\nfade", color.blue);

AddLabel(plusb13minusplus[1], "P: +13-+\nfake", color.dark_red);

AddLabel(plusb13plusminus[1], "P: +13+-\nsquat", color.pink);

AddLabel(minusb13plusplus[1], "P: -13++", color.green);

AddLabel(minusb13minusminus[1], "P: -13--", color.blue);

AddLabel(minusb13minusplus[1], "P: -13-+", color.dark_red);

AddLabel(minusb13plusminus[1], "P: -13+-", color.pink);

AddLabel(plusb31plusplus[1], "P: +31++", color.green);

AddLabel(plusb31minusminus[1], "P: +31--", color.blue);

AddLabel(plusb31minusplus[1], "P: +b31-+", color.dark_red);

AddLabel(plusb31plusminus[1], "P: +31+-", color.pink);

AddLabel(minusb31plusplus[1], "P: -31++\nGreen", color.green);

AddLabel(minusb31minusminus[1], "P: -31--\nfade", color.blue);

AddLabel(minusb31minusplus[1], "P: -31-+\nfake", color.dark_red);

AddLabel(minusb31plusminus[1], "P: -31+-\nsquat", color.pink);

AddLabel(plus23[1], "P: 23", color.gray);

AddLabel(plus12[1], "P: 12", color.gray);

AddLabel(plus21[1], "P: 21", color.gray);

AddLabel(plus32[1], "P: 32", color.gray);
This is perfect, the labels keep disappearing though, they will be there for a minute then disappear, is there a way we can get them to just stay on the screen?

Yeah I'm fine with the current bar appearing and disappearing but can we get the previous bar label to stay?

This may be a dumb question since I'm a total noob when it comes to Thinkscript, but if we got rid of the current bar and just kept the previous bar then could it stay on the chart? I've seen one other guy with a similar script and his label stayed on the chart. Thanks a ton for your help by the way.

I'm using a 1 minute 5minute and hourly mostly. I think comparisons from 2 bars ago is what I am looking for. the first solution you said, so the previous bar is compared to the bar before that essentially.

the use is more intended for the 1 minute and 5 minute chart. Thanks a ton for your help. I can't wait to use this! Also, im probably wrong but wouldn't it be two hours ago? if you have the previous bar's MFI and to get that you compare it to the bar before that?

This is what I am looking for
 
Last edited by a moderator:
@grandpa john
I was able to rewrite the calculations to stabilize the previous bar label WITHOUT having to resort to 2 bars ago!

In my testing this morning. It seems to be working well.

Ruby:
def MFI0 = (high - low) / volume;
def MFI1 = (high[1] - low[1]) / volume[1];

def MFIplus = MFI0 > MFI1;
def MFIminus = MFI0 < MFI1;

def meanplus = hl2 > high[1];
def meanminus = hl2 < high[1];

def volplus = volume > volume[1];
def volminus = volume < volume[1];

def b13 = open < hl2 and close > hl2 and close > open;
def b31 = open > hl2 and close < hl2 and close < open;

########### CURRENT BAR
def plusb13plusplus = meanplus and b13 and volplus and MFIplus;
AddLabel(plusb13plusplus, "C: +13++\nGreen", color.green);

def plusb13minusminus = meanplus and b13 and volminus and MFIminus;
AddLabel(plusb13minusminus, "C: +13--\nfade", color.blue);

def plusb13minusplus = meanplus and b13 and volminus and MFIplus;
AddLabel(plusb13minusplus, "C: +13-+\nfake", color.dark_red);

def plusb13plusminus = meanplus and b13 and volplus and MFIminus;
AddLabel(plusb13plusminus, "C: +13+-\nsquat", color.pink);

def minusb13plusplus = meanminus and b13 and volplus and MFIplus;
AddLabel(minusb13plusplus, "C: -13++", color.green);

def minusb13minusminus = meanminus and b13 and volminus and MFIminus;
AddLabel(minusb13minusminus, "C: -13--", color.blue);

def minusb13minusplus = meanminus and b13 and volminus and MFIplus;
AddLabel(minusb13minusplus, "C: -13-+", color.dark_red);

def minusb13plusminus = meanminus and b13 and volplus and MFIminus;
AddLabel(minusb13plusminus, "C: -13+-", color.pink);

def plusb31plusplus = meanplus and b31 and volplus and MFIplus;
AddLabel(plusb31plusplus, "C: +31++", color.green);

def plusb31minusminus = meanplus and b31 and volminus and MFIminus;
AddLabel(plusb31minusminus, "C: +31--", color.blue);

def plusb31minusplus = meanplus and b31 and volminus and MFIplus;
AddLabel(plusb31minusplus, "C: +b31-+", color.dark_red);

def plusb31plusminus = meanplus and b31 and volplus and MFIminus;
AddLabel(plusb31plusminus, "C: +31+-", color.pink);

def minusb31plusplus = meanminus and b31 and volplus and MFIplus;
AddLabel(minusb31plusplus, "C: -31++\nGreen", color.green);

def minusb31minusminus = meanminus and b31 and volminus and MFIminus;
AddLabel(minusb31minusminus, "C: -31--\nfade", color.blue);

def minusb31minusplus = meanminus and b31 and volminus and MFIplus;
AddLabel(minusb31minusplus, "C: -31-+\nfake", color.dark_red);

def minusb31plusminus = meanminus and b31 and volplus and MFIminus;
AddLabel(minusb31plusminus, "C: -31+-\nsquat", color.pink);

def plus23 = open > hl2 and close > hl2 and close > open;
AddLabel(plus23, "C: 23", color.gray);

def plus12 = open < hl2 and close < hl2 and close > open;
AddLabel(plus12, "C: 12", color.gray);

def plus21 = open < hl2 and close < hl2 and close < open;
AddLabel(plus21, "C: 21", color.gray);

def plus32 = open > hl2 and close > hl2 and close < open;
AddLabel(plus32, "C: 32", color.gray);

################# PERVIOUS BAR
def pplusb13plusplus = meanplus[1] and b13[1] and volplus[1] and MFIplus[1];
AddLabel(plusb13plusplus, "C: +13++\nGreen", color.green);

def pplusb13minusminus = meanplus[1] and b13[1] and volminus[1] and MFIminus[1];
AddLabel(pplusb13minusminus, "C: +13--\nfade", color.blue);

def pplusb13minusplus = meanplus[1] and b13[1] and volminus[1] and MFIplus[1];
AddLabel(pplusb13minusplus, "C: +13-+\nfake", color.dark_red);

def pplusb13plusminus = meanplus[1] and b13[1] and volplus[1] and MFIminus[1];
AddLabel(pplusb13plusminus, "C: +13+-\nsquat", color.pink);

def pminusb13plusplus = meanminus[1] and b13[1] and volplus[1] and MFIplus[1];
AddLabel(minusb13plusplus, "C: -13++", color.green);

def pminusb13minusminus = meanminus[1] and b13[1] and volminus[1] and MFIminus[1];
AddLabel(pminusb13minusminus, "C: -13--", color.blue);

def pminusb13minusplus = meanminus[1] and b13[1] and volminus[1] and MFIplus[1];
AddLabel(pminusb13minusplus, "C: -13-+", color.dark_red);

def pminusb13plusminus = meanminus[1] and b13[1] and volplus[1] and MFIminus[1];
AddLabel(pminusb13plusminus, "C: -13+-", color.pink);

def pplusb31plusplus = meanplus[1] and b31[1] and volplus[1] and MFIplus[1];
AddLabel(pplusb31plusplus, "C: +31++", color.green);

def pplusb31minusminus = meanplus[1] and b31[1] and volminus[1] and MFIminus[1];
AddLabel(pplusb31minusminus, "C: +31--", color.blue);

def pplusb31minusplus = meanplus[1] and b31[1] and volminus[1] and MFIplus[1];
AddLabel(pplusb31minusplus, "C: +b31-+", color.dark_red);

def pplusb31plusminus = meanplus[1] and b31[1] and volplus[1] and MFIminus[1];
AddLabel(pplusb31plusminus, "C: +31+-", color.pink);

def pminusb31plusplus = meanminus[1] and b31[1] and volplus[1] and MFIplus[1];
AddLabel(pminusb31plusplus, "C: -31++\nGreen", color.green);

def pminusb31minusminus = meanminus[1] and b31[1] and volminus[1] and MFIminus[1];
AddLabel(pminusb31minusminus, "C: -31--\nfade", color.blue);

def pminusb31minusplus = meanminus[1] and b31[1] and volminus[1] and MFIplus[1];
AddLabel(pminusb31minusplus, "C: -31-+\nfake", color.dark_red);

def pminusb31plusminus = meanminus[1] and b31[1] and volplus[1] and MFIminus[1];
AddLabel(pminusb31plusminus, "C: -31+-\nsquat", color.pink);

def pplus23 = open[1] > hl2[1] and close[1] > hl2[1] and close[1] > open[1];
AddLabel(pplus23, "C: 23", color.gray);

def pplus12 = open[1] < hl2[1] and close[1] < hl2[1] and close[1] > open[1];
AddLabel(pplus12, "C: 12", color.gray);

def pplus21 = open[1] < hl2[1] and close[1] < hl2[1] and close[1] < open[1];
AddLabel(pplus21, "C: 21", color.gray);

def pplus32 = open[1] > hl2[1] and close[1] > hl2[1] and close[1] < open[1];
AddLabel(pplus32, "C: 32", color.gray);
 
Last edited:
@grandpa john
I was able to rewrite the calculations to stabilize the previous bar label WITHOUT having to resort to 2 bars ago!

In my testing this morning. It seems to be working well.

Ruby:
def MFI0 = (high - low) / volume;
def MFI1 = (high[1] - low[1]) / volume[1];

def MFIplus = MFI0 > MFI1;
def MFIminus = MFI0 < MFI1;

def meanplus = hl2 > high[1];
def meanminus = hl2 < high[1];

def volplus = volume > volume[1];
def volminus = volume < volume[1];

def b13 = open < hl2 and close > hl2 and close > open;
def b31 = open > hl2 and close < hl2 and close < open;

########### CURRENT BAR
def plusb13plusplus = meanplus and b13 and volplus and MFIplus;
AddLabel(plusb13plusplus, "C: +13++\nGreen", color.green);

def plusb13minusminus = meanplus and b13 and volminus and MFIminus;
AddLabel(plusb13minusminus, "C: +13--\nfade", color.blue);

def plusb13minusplus = meanplus and b13 and volminus and MFIplus;
AddLabel(plusb13minusplus, "C: +13-+\nfake", color.dark_red);

def plusb13plusminus = meanplus and b13 and volplus and MFIminus;
AddLabel(plusb13plusminus, "C: +13+-\nsquat", color.pink);

def minusb13plusplus = meanminus and b13 and volplus and MFIplus;
AddLabel(minusb13plusplus, "C: -13++", color.green);

def minusb13minusminus = meanminus and b13 and volminus and MFIminus;
AddLabel(minusb13minusminus, "C: -13--", color.blue);

def minusb13minusplus = meanminus and b13 and volminus and MFIplus;
AddLabel(minusb13minusplus, "C: -13-+", color.dark_red);

def minusb13plusminus = meanminus and b13 and volplus and MFIminus;
AddLabel(minusb13plusminus, "C: -13+-", color.pink);

def plusb31plusplus = meanplus and b31 and volplus and MFIplus;
AddLabel(plusb31plusplus, "C: +31++", color.green);

def plusb31minusminus = meanplus and b31 and volminus and MFIminus;
AddLabel(plusb31minusminus, "C: +31--", color.blue);

def plusb31minusplus = meanplus and b31 and volminus and MFIplus;
AddLabel(plusb31minusplus, "C: +b31-+", color.dark_red);

def plusb31plusminus = meanplus and b31 and volplus and MFIminus;
AddLabel(plusb31plusminus, "C: +31+-", color.pink);

def minusb31plusplus = meanminus and b31 and volplus and MFIplus;
AddLabel(minusb31plusplus, "C: -31++\nGreen", color.green);

def minusb31minusminus = meanminus and b31 and volminus and MFIminus;
AddLabel(minusb31minusminus, "C: -31--\nfade", color.blue);

def minusb31minusplus = meanminus and b31 and volminus and MFIplus;
AddLabel(minusb31minusplus, "C: -31-+\nfake", color.dark_red);

def minusb31plusminus = meanminus and b31 and volplus and MFIminus;
AddLabel(minusb31plusminus, "C: -31+-\nsquat", color.pink);

def plus23 = open > hl2 and close > hl2 and close > open;
AddLabel(plus23, "C: 23", color.gray);

def plus12 = open < hl2 and close < hl2 and close > open;
AddLabel(plus12, "C: 12", color.gray);

def plus21 = open < hl2 and close < hl2 and close < open;
AddLabel(plus21, "C: 21", color.gray);

def plus32 = open > hl2 and close > hl2 and close < open;
AddLabel(plus32, "C: 32", color.gray);

################# PERVIOUS BAR
def pplusb13plusplus = meanplus[1] and b13[1] and volplus[1] and MFIplus[1];
AddLabel(plusb13plusplus, "C: +13++\nGreen", color.green);

def pplusb13minusminus = meanplus[1] and b13[1] and volminus[1] and MFIminus[1];
AddLabel(pplusb13minusminus, "C: +13--\nfade", color.blue);

def pplusb13minusplus = meanplus[1] and b13[1] and volminus[1] and MFIplus[1];
AddLabel(pplusb13minusplus, "C: +13-+\nfake", color.dark_red);

def pplusb13plusminus = meanplus[1] and b13[1] and volplus[1] and MFIminus[1];
AddLabel(pplusb13plusminus, "C: +13+-\nsquat", color.pink);

def pminusb13plusplus = meanminus[1] and b13[1] and volplus[1] and MFIplus[1];
AddLabel(minusb13plusplus, "C: -13++", color.green);

def pminusb13minusminus = meanminus[1] and b13[1] and volminus[1] and MFIminus[1];
AddLabel(pminusb13minusminus, "C: -13--", color.blue);

def pminusb13minusplus = meanminus[1] and b13[1] and volminus[1] and MFIplus[1];
AddLabel(pminusb13minusplus, "C: -13-+", color.dark_red);

def pminusb13plusminus = meanminus[1] and b13[1] and volplus[1] and MFIminus[1];
AddLabel(pminusb13plusminus, "C: -13+-", color.pink);

def pplusb31plusplus = meanplus[1] and b31[1] and volplus[1] and MFIplus[1];
AddLabel(pplusb31plusplus, "C: +31++", color.green);

def pplusb31minusminus = meanplus[1] and b31[1] and volminus[1] and MFIminus[1];
AddLabel(pplusb31minusminus, "C: +31--", color.blue);

def pplusb31minusplus = meanplus[1] and b31[1] and volminus[1] and MFIplus[1];
AddLabel(pplusb31minusplus, "C: +b31-+", color.dark_red);

def pplusb31plusminus = meanplus[1] and b31[1] and volplus[1] and MFIminus[1];
AddLabel(pplusb31plusminus, "C: +31+-", color.pink);

def pminusb31plusplus = meanminus[1] and b31[1] and volplus[1] and MFIplus[1];
AddLabel(pminusb31plusplus, "C: -31++\nGreen", color.green);

def pminusb31minusminus = meanminus[1] and b31[1] and volminus[1] and MFIminus[1];
AddLabel(pminusb31minusminus, "C: -31--\nfade", color.blue);

def pminusb31minusplus = meanminus[1] and b31[1] and volminus[1] and MFIplus[1];
AddLabel(pminusb31minusplus, "C: -31-+\nfake", color.dark_red);

def pminusb31plusminus = meanminus[1] and b31[1] and volplus[1] and MFIminus[1];
AddLabel(pminusb31plusminus, "C: -31+-\nsquat", color.pink);

def pplus23 = open[1] > hl2[1] and close[1] > hl2[1] and close[1] > open[1];
AddLabel(pplus23, "C: 23", color.gray);

def pplus12 = open[1] < hl2[1] and close[1] < hl2[1] and close[1] > open[1];
AddLabel(pplus12, "C: 12", color.gray);

def pplus21 = open[1] < hl2[1] and close[1] < hl2[1] and close[1] < open[1];
AddLabel(pplus21, "C: 21", color.gray);

def pplus32 = open[1] > hl2[1] and close[1] > hl2[1] and close[1] < open[1];
AddLabel(pplus32, "C: 32", color.gray);
Exactly what I'm looking for! THANK YOU
 
I found the following color scheme to be easier to interpret:

"Green" rename to "Aggression" and color light blue. "Fade" color purple (similar to the divergence coloration for the UseThinkScript price action reader). "Fake" color dark orange. Squat color yellow (because I usually use yellow as a pivot or squeeze signal color).

That is what I use on the 1H chart, with the candles colored accordingly. For the 1min chart, I instead use a gradient from white to dark gray in the order of aggression -> fade -> fake -> squat.

I think this is an interesting study and it appears helpful based on watching the market today.

I do have a question: I don't understand the rationale behind the naming scheme for the various conditions as "21" "12 "31 "13" etc. Is it helpful to understand what these actually mean or is it only important to note the alternation between the four possible states (in the original study called "Green," "Fade," "Fake," and "Squat")?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
321 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top