# Price/Volume Value Histogram for ThinkOrSwim

#### samer800

##### Well-known member

Author Message:
An interesting implementation of mine to measure an asset changes based on asset price velocity and volume velocity. The indicator acts as asset value calculator. Long and Short.
==Points System Rules==
UPTRENDING
If Current Close is higher than previous Close and Current Volume is bigger than previous Volume: Adds Close Points and Volume Points
Otherwise check
If Current Close is higher than previous Close: Adds Only Close Points

DOWNTRENDING
If Current Close is lower than previous Close and Current Volume is bigger than previous Volume: Reduces Close Points and Volume Points
Otherwise check
If Current Close is lower than previous Close: Reduces Only Close Points

==Plotting==
Result of the values are summed up to a histogram.
Obviously on increasing prices and volume the histogram will be above zero line and on the Bullish side (green color), otherwise, on the Bearish side (red color).

You can't cheat the price movement, it's just what it is.
Optional to smooth it by EMA (set to true by default).

CODE:
CSS:
``````#// This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License
#study("Price/Volume value histogram","P/V value histogram",overlay=false,precision=3)
# Converted by [email protected] - 01/2023
Declare lower;
input lookBack = 7;              # "Look back"
input colorBars = yes;           # "Color bars"
input percent_factor_volume = 0; # "Percent to reduce from volume factor [0 - normal, 100 - disable volume]"
input emaSmooth = yes;           # "EMA smoothing"
input emaLength = 7;             # "EMA Length"

def na = Double.NaN;
def reduced_percent;
if BarNumber()==1 {
reduced_percent = if (percent_factor_volume==0) then 1 else 0;
} else {
reduced_percent = AbsValue(percent_factor_volume/100-1);
}
def points_array;
def points;
def points_max;
def max_totals;
def points_totals;
#//Positive
if close>close[1] and (volume>volume[1]) {
points_array = (close/close[1])*(max(min(volume/volume[1],2)*reduced_percent,1));
points = points[1] + 1;
points_totals = points_array / points;
points_max = points_max[1] + points_totals;
max_totals = if points_max[1] == 0 then points_totals[1] else points_totals;
} else if close>close[1] {
points_array = (close/close[1]);
points = points[1] + 1;
points_totals = points_array / points;
points_max = points_max[1] + points_totals;
max_totals = if points_max[1] == 0 then points_totals[1] else points_totals;
#//Negative
} else
if  close<close[1] and (volume>volume[1]) {
points_array = -((close[1]/close)*(max(min(volume/volume[1],2)*reduced_percent,1)));
points = points[1] + 1;
points_totals = points_array / points;
points_max = points_max[1] + points_totals;
max_totals = if points_max[1] == 0 then points_totals[1] else points_totals;
} else if close<close[1] {
points_array = -(close[1]/close);
points = points[1] + 1;
points_totals = points_array / points;
points_max = points_max[1] + points_totals;
max_totals = if points_max[1] == 0 then points_totals[1] else points_totals;
} else {
points_array = points_array[1];
points = points[1];
points_max = points_max[1];
points_totals = points_totals[1];
max_totals = max_totals[1];
}

def sumTotal = fold i1 = 1 to lookBack + 1 with p1 do
p1 +  points_totals[i1] / i1;
def sum_total = sumTotal;
plot ZeroLine = if isNaN(close) then na else 0;
ZeroLine.SetDefaultColor(Color.GRAY);

def _result = if emaSmooth then ExpAverage(sum_total,emaLength) else sum_total;
def ExtUp = _result>=0 and _result>_result[1];
def    Up = _result>=0 and _result<_result[1];
def ExtDn = _result<0 and _result<_result[1];
def    Dn = _result<0 and _result>_result[1];
plot plot_result = if isNaN(close) then na else _result;
plot_result.SetLineWeight(4);
plot_result.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
plot_result.AssignValueColor(if ExtUp then Color.GREEN else
if Up    then Color.DARK_GREEN else
if ExtDn then Color.RED else
if Dn    then Color.DARK_RED else Color.GRAY);

AssignPriceColor(if !colorBars then Color.CURRENT else
if ExtUp then Color.GREEN else
if Up    then Color.DARK_GREEN else
if ExtDn then Color.RED else
if Dn    then Color.DARK_RED else Color.GRAY);

# --- END CODE``````

Last edited by a moderator:

87k+ Posts
265 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?