Volume Flow Indicator (VFI) from Markos Katsanos For ThinkOrSwim

markos

Well-known member
VIP
This is from the same article as the FVE Indicator that is meant for short term trading. If someone could port this... much obliged.
Website: http://mkatsanos.com/VFI.htmlThe VFI is based on the popular On Balance Volume (OBV) but with three very important modifications:

  • Unlike the OBV, indicator values are no longer meaningless. Positive readings are bullish and negative bearish.
  • The calculation is based on the day's median instead of the closing price.
  • A volatility threshold takes into account minimal price changes and another threshold eliminates excessive volume.
  • The indicator takes into account only the latest 6 month volume action and not the entire data loaded in the chart.
 
Last edited by a moderator:

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

@dolomick This is actually quite a good idea! Per your request I combined the TOS Volume Flow Indicator with the Relative Volume StDev study with the following characteristics. If a spike > 2 standard deviation is detected on the Relative Volume StDev, a GREEN dot is plotted. When this event happens, a label is displayed and an audible alert will be generated. In order to verify the results, also load the standard TOS Relative Volume StDev that displays on a lower chart. You'll see that the signals match up nicely. Have fun!

Code:
# Volume Flow with Relative Volume StDev Spike > 2 StDev
# tomsk
# 1.11.2020

# This study combines the TOS Volume Flow Indicator with the Relative Volume StDev study
# If a spike > 2 standard deviation is detected on the Relative Volume StDev, a GREEN dot is plotted.
# When this event happens, a label is displayed and an audible alert will be generated

declare lower;

# Volume Flow Indicator

input VFlength = 130;
input maxVolumeCutOff = 2.5;

assert(maxVolumeCutOff > 0, "'max volume cut off' must be positive: " + maxVolumeCutOff);

def cutOff = 0.2 * stdev(log(hlc3) - log(hlc3[1]), 30) * close;
def hlcChange = hlc3 - hlc3[1];
def avgVolume = Average(volume, 50)[1];
def minVolume = Min(volume, avgVolume * maxVolumeCutOff);
def dirVolume = if hlcChange > cutOff
    then minVolume
    else if hlcChange < -cutOff
        then -minVolume
        else 0;

plot VFI = ExpAverage(sum(dirVolume, VFlength) / avgVolume, 3);
plot ZeroLine = 0;

VFI.setDefaultColor(Color.Magenta);
ZeroLine.setDefaultColor(Color.Gray);

# Relative Volume StDev Spike > 2 StDev

input RVlength = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, RVlength)) / StDev(volume, RVlength);
def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);

plot RVSpike = if IsNaN(close) then Double.NaN
               else if RelVol > numDev then 0 
               else Double.NaN;
RVSpike.SetPaintingStrategy(PaintingStrategy.Points);
RVSpike.SetLineWeight(5);
RVSpike.SetDefaultColor(Color.Green);
AddLabel(!isNaN(RVSpike), "Relative Volume Spike > 2 StDev", Color.Yellow);
Alert(!isNaN(RVSpike), "Relative Volume Spike > 2 StDev", Alert.BAR, Sound.Ring);
# End Volume Flow with Relative Volume StDev Spike > 2 StDev
 
Can anyone combine this with the default RelativeVolumeStDev study in TOS for me? I am open to different implementation ideas, but I was thinking maybe the Relative volume would be centered on the zero line of the Volume Flow indicator. Combined would be very useful and take less lower screen space.
 
Thanks so much! I had another idea and had actually deleted this post as I didnt want to create too much work, but since it’s done I will use it for sure!
My related idea was to add the relative volume std dev study to this https://usethinkscript.com/threads/...th-hot-percent-for-thinkorswim.389/#post-2542

I am again open to how to best implement, but I do think it would be useful to have a way to indicate if the relative vol std deviation is over 2, over 3, over 4, etc. for any given volume bar. I think a label would get overlooked, so ideally something near the actual volume bar. Maybe a bubble with relative vol std dev value in it at the relevant volume bar? I think that would make a great study even greater.
 
@dolomick At least for the Relative Volume StDev Spike > 2 StDev the same information can be seen with the hot percent triangle. If you check it will plot at the same bars depending on the % you set.
 
Really enjoying this study and I am trying to add the force index to it, but I am having some problems getting it to display. I can get either the volume flows to display, or the force index, but not both at the same time. I just copied the Force Index code into the Volume Flow with standard deviation code so that is where I am at currently.

Code:
# Volume Flow with Relative Volume StDev Spike > 2 StDev
# tomsk
# 1.11.2020

# This study combines the TOS Volume Flow Indicator with the Relative Volume StDev study
# If a spike > 2 standard deviation is detected on the Relative Volume StDev, a GREEN dot is plotted.
# When this event happens, a label is displayed and an audible alert will be generated

declare lower;

# Volume Flow Indicator

input VFlength = 14;
input maxVolumeCutOff = 2.5;

input VFlength2 = 14;



assert(maxVolumeCutOff > 0, "'max volume cut off' must be positive: " + maxVolumeCutOff);

def cutOff = 0.2 * stdev(log(hlc3) - log(hlc3[1]), 30) * close;
def hlcChange = hlc3 - hlc3[1];
def avgVolume = Average(volume, 50)[1];
def minVolume = Min(volume, avgVolume * maxVolumeCutOff);
def dirVolume = if hlcChange > cutOff
    then minVolume
    else if hlcChange < -cutOff
        then -minVolume
        else 0;

plot VFI = ExpAverage(sum(dirVolume, VFlength) / avgVolume, 3);
plot ZeroLine = 0;
plot VFI2 = ExpAverage(sum(dirVolume, VFlength2) / avgVolume, 3);
VFI2.setDefaultColor(Color.Orange);
VFI.setDefaultColor(Color.Magenta);
ZeroLine.setDefaultColor(Color.Gray);





# Relative Volume StDev Spike > 2 StDev

input RVlength = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, RVlength)) / StDev(volume, RVlength);
def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);

plot RVSpike = if IsNaN(close) then Double.NaN
               else if RelVol > numDev then 0
               else Double.NaN;
RVSpike.SetPaintingStrategy(PaintingStrategy.Points);
RVSpike.SetLineWeight(5);
RVSpike.SetDefaultColor(Color.Green);
AddLabel(!isNaN(RVSpike), "Relative Volume Spike > 2 StDev", Color.Yellow);
Alert(!isNaN(RVSpike), "Relative Volume Spike > 2 StDev", Alert.BAR, Sound.Ring);
# End Volume Flow with Relative Volume StDev Spike > 2 StDev




#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
# Force Index
# I removed the "declare lower" and changed the length to  "length3" but it is not working.



input length3 = 13;

plot FI = ExpAverage(data = (close - close[1]) * volume, length3);
FI.SetDefaultColor(GetColor(8));
 
Scaling problem. FI scale is compressing the other plots. Try multiplying the FI value by a decimal factor.
 
@dolomick -- I replaced the code for the last added indicator (from inputlength3 on...) with this:
Code:
input length_force = 13;
input force_mult = 0.0001;
plot FI = ExpAverage(data = (close - close[1]) * volume, length_force) * force_mult;
I'm sure there's a more intelligent way to calculate the force_mult so that it would be dynamic, as in my testing I found I occasionally had to change it by an order of magnitude (both larger sometimes and smaller others), but I leave that to you (it's a ratio between the FI values which tend to be very large) and the others (which are many times smaller... usually). I simply decided to make it an input so that I could alter it without having to edit the script.

Hope it helps. And thanks for taking a swing at it yourself. We learn best by doing, eh?

Happy Trading,
Mashume

P.S. While I found this combination of indicators interesting, can you give some idea of what you were looking for, signals you thought you might find, or any other insight into the process you were going through in tying these together? :-D
 
Last edited:
@mashume Thanks so much. I found volume flow indicator can be a leading indicator and help establish overall trend or help show future direction, but I like to have it set at 9 and 21 volume flow length for a shorter and longer term view of the situation. I found that by adding Force index as an oscillator sort of like the awesome oscillator (set to numerical, then select the vertical lines for the "draw as" input), it allows me to see reversals or "forceful" moves. I pair it with the cumulative delta indicator that has been posted here, and the force index helps me find the reversal points. Another use I have found is that if I see a large force index bar against the prevailing trend, it is often a good scalping opportunity to scalp back in the direction of the prevailing trend. I am fond of volume based indicators as they have almost no lag, and they are generally under-used in my opinion.
 
Cannot get this to work correctly. However it will plot the studies together without worrying about changing an input. The main idea of seeing the force index spikes should still work.
Code:
script normalizePlot {
    input data = close;
    input newRngMin =  -1;
    input newRngMax = 1;
    def hhData = HighestAll( data );
    def llData = LowestAll( data );
    plot nr = ((( newRngMax - newRngMin ) * ( data - llData )) / ( hhData - llData )) + newRngMin;
}

script fiScale{
    input Length3 = 13;
    input volume = volume;
   input data = close;
    def FI = ExpAverage((data - data[1]) * volume, Length3);
    plot fis  = FI;
}

plot fis = normalizePlot (fiScale("data" = close , "volume" = volume, "length3" = Length3), -20, 20);
 
@mashume Thanks so much. I found volume flow indicator can be a leading indicator and help establish overall trend or help show future direction, but I like to have it set at 9 and 21 volume flow length for a shorter and longer term view of the situation. I found that by adding Force index as an oscillator sort of like the awesome oscillator (set to numerical, then select the vertical lines for the "draw as" input), it allows me to see reversals or "forceful" moves. I pair it with the cumulative delta indicator that has been posted here, and the force index helps me find the reversal points. Another use I have found is that if I see a large force index bar against the prevailing trend, it is often a good scalping opportunity to scalp back in the direction of the prevailing trend. I am fond of volume based indicators as they have almost no lag, and they are generally under-used in my opinion.
Could you give link to your Chart? Thanks
 
@mashume Thanks so much. I found volume flow indicator can be a leading indicator and help establish overall trend or help show future direction, but I like to have it set at 9 and 21 volume flow length for a shorter and longer term view of the situation. I found that by adding Force index as an oscillator sort of like the awesome oscillator (set to numerical, then select the vertical lines for the "draw as" input), it allows me to see reversals or "forceful" moves. I pair it with the cumulative delta indicator that has been posted here, and the force index helps me find the reversal points. Another use I have found is that if I see a large force index bar against the prevailing trend, it is often a good scalping opportunity to scalp back in the direction of the prevailing trend. I am fond of volume based indicators as they have almost no lag, and they are generally under-used in my opinion.
dolomick, hope you get a notification for this as I'm just now seeing this? Question, "I like to have it set for 9 and 21 volume flow length" do you mean the v flength and the r vlength set at 9 & 21? Also, are you using this configuration on a 1min & 5min chart? https://drive.google.com/file/d/10pDlMfq5_gCc0gIdL9j6Thj2isfDmu5S/view?usp=share_link

That link is a google drive link. I took a screen shot of my settings.
 
Last edited by a moderator:
dolomick, hope you get a notification for this as I'm just now seeing this? Question, "I like to have it set for 9 and 21 volume flow length" do you mean the v flength and the r vlength set at 9 & 21? Also, are you using this configuration on a 1min & 5min chart? https://drive.google.com/file/d/10pDlMfq5_gCc0gIdL9j6Thj2isfDmu5S/view?usp=share_link
Did you know that by clicking on a member's name, you can easily check when they were last seen on the uTS forum? It's a great way to keep track of who's been around recently, and who hasn't. Speaking of which, it looks like @dolomick is no longer active. :(
 
Did you know that by clicking on a member's name, you can easily check when they were last seen on the uTS forum? It's a great way to keep track of who's been around recently, and who hasn't. Speaking of which, it looks like @dolomick is no longer active. :(
Oh shoot that's a bummer! I didn't know about clicking the name of the member to know if they're active...Good stuff, thanks.
 
@dolomick This is actually quite a good idea! Per your request I combined the TOS Volume Flow Indicator with the Relative Volume StDev study with the following characteristics. If a spike > 2 standard deviation is detected on the Relative Volume StDev, a GREEN dot is plotted. When this event happens, a label is displayed and an audible alert will be generated. In order to verify the results, also load the standard TOS Relative Volume StDev that displays on a lower chart. You'll see that the signals match up nicely. Have fun!

Code:
# Volume Flow with Relative Volume StDev Spike > 2 StDev
# tomsk
# 1.11.2020

# This study combines the TOS Volume Flow Indicator with the Relative Volume StDev study
# If a spike > 2 standard deviation is detected on the Relative Volume StDev, a GREEN dot is plotted.
# When this event happens, a label is displayed and an audible alert will be generated

declare lower;

# Volume Flow Indicator

input VFlength = 130;
input maxVolumeCutOff = 2.5;

assert(maxVolumeCutOff > 0, "'max volume cut off' must be positive: " + maxVolumeCutOff);

def cutOff = 0.2 * stdev(log(hlc3) - log(hlc3[1]), 30) * close;
def hlcChange = hlc3 - hlc3[1];
def avgVolume = Average(volume, 50)[1];
def minVolume = Min(volume, avgVolume * maxVolumeCutOff);
def dirVolume = if hlcChange > cutOff
    then minVolume
    else if hlcChange < -cutOff
        then -minVolume
        else 0;

plot VFI = ExpAverage(sum(dirVolume, VFlength) / avgVolume, 3);
plot ZeroLine = 0;

VFI.setDefaultColor(Color.Magenta);
ZeroLine.setDefaultColor(Color.Gray);

# Relative Volume StDev Spike > 2 StDev

input RVlength = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, RVlength)) / StDev(volume, RVlength);
def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);

plot RVSpike = if IsNaN(close) then Double.NaN
               else if RelVol > numDev then 0 
               else Double.NaN;
RVSpike.SetPaintingStrategy(PaintingStrategy.Points);
RVSpike.SetLineWeight(5);
RVSpike.SetDefaultColor(Color.Green);
AddLabel(!isNaN(RVSpike), "Relative Volume Spike > 2 StDev", Color.Yellow);
Alert(!isNaN(RVSpike), "Relative Volume Spike > 2 StDev", Alert.BAR, Sound.Ring);
# End Volume Flow with Relative Volume StDev Spike > 2 StDev


Can someone pls explain what the option : "allow negative values" means?

Also, does the 2 stdev spike also trigger when the bearish volume is high (below zero line)
 
Can someone pls explain what the option : "allow negative values" means?

Also, does the 2 stdev spike also trigger when the bearish volume is high (below zero line)
  • "allow negative values" = is where the volume is less than the average volume.
  • all spikes are plotted regardless if the VFI is below the zero line
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
364 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