Finite Volume Elements (FVE) for ThinkOrSwim

Would you mind sharing the study code or chart with the fix, please?

Code:
#
# FiniteVolumeElements_FVE
#
# Author: Kory Gill, [USER=212]@korygill[/USER]
#
# Created from idea on https://usethinkscript.com/threads/finite-volume-elements.593/
# Original idea is from http://mkatsanos.com/FVE.html
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190907-1200-KG    - Created.
# ...7/20/2020 Added MTF Capability in order to combat the fact that it does not appear on lower than 2 minute time frames### Ramon Del Villar AKA Pelonsax
# ...

declare lower;
input AGG = aggregationPeriod.FIVE_MIN;
input CutOff = 0.003;
input Samples_Used = 22;
def samples = Samples_Used * (AGG/60000);

def bn = BarNumber();
def nan = double.NaN;

def tp = hlc3(period = AGG);
def mf = (close(period = AGG) - (high(period = AGG)+low(period = AGG))/2) + tp - tp[1];
def fveFactor = if mf > (CutOff*Close(period = AGG))
                then 1
                else if mf < (-1*CutOff*Close(period = AGG)) then -1
                else 0;

def VolumePlusMinus = volume(period = AGG) * fveFactor;
def fveSum = Sum(VolumePlusMinus, Samples);
def fve = if bn > Samples
          then (fveSum / (Average(volume(period = AGG),Samples) * Samples)) * 100
          else nan;

plot pFVE = fve;

plot pFVE_MA = MovingAverage(AverageType.SIMPLE, fve, 30);
pFVE_MA.SetDefaultColor(Color.Gray);
PFVE_MA.SetPaintingStrategy(PaintingStrategy.DASHES);

plot zeroLine = 0;
zeroLine.SetDefaultColor(Color.White);
 

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

I'VE DONE IT!!!!!!!! OMFG I CAN'T BELIEVE I DID IT!!! (Okay, truth is, this is a little over my head, but I think I did it. You be the judge)

Ladies and Gentlemen......

Spike_Dampened_Finite_Volume_Elements (I suppose another way of calling it could be "NORMALIZED_FINITE_VOLUME_ELEMENTS")

I took the logic from Volume Flow Indicator which is a normalized version of On Balance Volume and applied it here. Below are the indicators in question back to back. Previously, I had thought that the only way to show the original FVE study on a one minute chart was to change the aggregation, but as you can see, there is no need to do that with this "Normalized" Version (though it is possible if one were so inclined.

f3LzNWO.png


Here is the code to the dampened indicator:

Code:
# FiniteVolumeElements_FVE
#
# Author: Kory Gill, [USER=212]@korygill[/USER]
#
# Created from idea on https://usethinkscript.com/threads/finite-volume-elements.593/
# Original idea is from http://mkatsanos.com/FVE.html
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190907-1200-KG    - Created.

###############################################################################
### NORMALIZATION (Volume Damping adaptation) by Ramon Del Villar AKA PElonsax
### 7/20/2020 #################################################################
###############################################################################
# The damping logic is taken directly from VFI #

declare once_per_bar;
declare lower;

#
# inputs
#
input Samples = 22;

#
# logic
#
def bn = BarNumber();
def nan = double.NaN;


input maxVolumeCutOff = 2.5;
###Coefficient used in calculation of “Cut Off” value. Lower values mean stronger damping of volume spikes###

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, 30)[1];
def minVolume = Min(volume, avgVolume * maxVolumeCutOff);
def dirVolume = if hlcChange > cutOff
    then minVolume
    else if hlcChange < -cutOff
        then -minVolume
        else 0;


def mf = (close - (high+low)/2) + hlc3 - hlc3 [1];
def fveSum = Sum(dirVolume, Samples);

def fve = if bn > Samples
          then (fveSum / (Average(avgVolume, Samples) * Samples)) * 100
          else nan;


#
# plots
#
plot pFVE = fve;

plot pFVE_MA = MovingAverage(AverageType.SIMPLE, fve, 30);
pFVE_MA.SetDefaultColor(Color.Gray);
PFVE_MA.SetPaintingStrategy(PaintingStrategy.DASHES);

plot zeroLine = 0;
zeroLine.SetDefaultColor(Color.White);

Here is a shareable link:

https://tos.mx/asxD578
ENJOY!!
 
This looks fascinating. I can see how this would be very valuable. Would you mind offering a small bit of commentary on how exactly you use this?

Also would you mind sharing the MTF volume elements code also?
 
Last edited by a moderator:
@petey150

Code:
# to chg the length of the moving average, change line#17: The "30" represents length
def FVE_MA = MovingAverage(AverageType.SIMPLE, fve, 30);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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