How to Adjust Volume Bars for Volume Spikes (Truncate)

When an unusual amount of volume happens on any given time frame, the resulting volume bar will tend to skew the rest of the volume bars in view. In order to accommodate the large volume bar for the volume spike, the other volume bars become unusually small. This makes volume trends difficult to see.

Can we truncate (adjust) those spike volume bars to maintain a more balanced volume view.

Something like this:
xKVvHia.png



OTv973j.png


Here is the working script so far:

#----------------------------------------------------------------------------
# Author: IsItPossible
#
# Name: My_Volume_Truncate_Spikes
# Summary: This study can be used as an indicator which helps us suppress
# when an unusual amount of volume happens on any given time frame, the resulting
# volume bar will tend to skew the rest of the volume bars in view. In order to
# accommodate the large volume bar for the volume spike, the other volume bars become
# unusually small. This makes volume trends difficult to see.
#
# This indicator truncates (adjust) those volume spike bars to maintain a more
# balanced volume view.
#
#----------------------------------------------------------------------------

declare lower;

# Define input parameters
input thresholdMultiplier = 2.0; #Hint thresholdMultiplier: Specify the threshold multiplier for identifying volume spikes
input avgLength = 50; #Hint avgLength: Specify the bars to be considered to calculate average volume
input ColorAsPrice = {default false, true};

# Calculate the average volume over a specified period
def averageVolume = Average(volume, avgLength);

# Calculate the threshold volume level
def thresholdVolume = averageVolume * thresholdMultiplier;

# Identify volume spikes
def isVolumeSpike = volume > thresholdVolume;

# Plotting volume spikes
def maxPeriod = if GetAggregationPeriod() == AggregationPeriod.DAY then 252 else if GetAggregationPeriod() < AggregationPeriod.WEEK then 50 else if GetAggregationPeriod() < AggregationPeriod.MONTH then 12 else 10;

plot VolumeSpike = isVolumeSpike and Highest(thresholdVolume, maxPeriod) < volume;
VolumeSpike.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
VolumeSpike.SetDefaultColor(Color.LIGHT_ORANGE);

# Truncating volume spikes
def truncatedVolume = if isVolumeSpike and Highest(thresholdVolume,maxPeriod ) < volume then Highest(thresholdVolume, maxPeriod) else volume;

# Plotting truncated volume
plot TruncatedVolumep = truncatedVolume;
#TruncatedVolumep.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TruncatedVolumep.SetDefaultColor(Color.CURRENT);

TruncatedVolumep.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#TruncatedVolumep.SetLineWeight(3);
TruncatedVolumep.DefineColor("Up", Color.UPTICK);
TruncatedVolumep.DefineColor("Down", Color.DOWNTICK);
TruncatedVolumep.DefineColor("Current", Color.CYAN);
TruncatedVolumep.AssignValueColor(if ColorAsPrice then (if close > close[1] then TruncatedVolumep.Color("Up") else if close < close[1] then TruncatedVolumep.Color("Down") else GetColor(1)) else TruncatedVolumep.Color("Current") );
 
Last edited:
Solution
When an unusual amount of volume happens on any given time frame, the resulting volume bar will tend to skew the rest of the volume bars in view. In order to accommodate the large volume bar for the volume spike, the other volume bars become unusually small. This makes volume trends difficult to see.

Can we truncate (adjust) those spike volume bars to maintain a more balanced volume view.

Something like this:
xKVvHia.png



OTv973j.png


Here is the working script so far:

#----------------------------------------------------------------------------
# Author: IsItPossible
#
# Name: My_Volume_Truncate_Spikes
# Summary: This study can be used as an indicator which helps us suppress
#...
One thing that helps is adding a label into the volume script. The label I have right now is " " so it says nothing and is the same color as my background so I don't even see it. Helps a ton
 

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

When an unusual amount of volume happens on any given time frame, the resulting volume bar will tend to skew the rest of the volume bars in view. In order to accommodate the large volume bar for the volume spike, the other volume bars become unusually small. This makes volume trends difficult to see.

Can we truncate (adjust) those spike volume bars to maintain a more balanced volume view.

Something like this:
xKVvHia.png



OTv973j.png


Here is the working script so far:

#----------------------------------------------------------------------------
# Author: IsItPossible
#
# Name: My_Volume_Truncate_Spikes
# Summary: This study can be used as an indicator which helps us suppress
# when an unusual amount of volume happens on any given time frame, the resulting
# volume bar will tend to skew the rest of the volume bars in view. In order to
# accommodate the large volume bar for the volume spike, the other volume bars become
# unusually small. This makes volume trends difficult to see.
#
# This indicator truncates (adjust) those volume spike bars to maintain a more
# balanced volume view.
#
#----------------------------------------------------------------------------

declare lower;

# Define input parameters
input thresholdMultiplier = 2.0; #Hint thresholdMultiplier: Specify the threshold multiplier for identifying volume spikes
input avgLength = 50; #Hint avgLength: Specify the bars to be considered to calculate average volume
input ColorAsPrice = {default false, true};

# Calculate the average volume over a specified period
def averageVolume = Average(volume, avgLength);

# Calculate the threshold volume level
def thresholdVolume = averageVolume * thresholdMultiplier;

# Identify volume spikes
def isVolumeSpike = volume > thresholdVolume;

# Plotting volume spikes
def maxPeriod = if GetAggregationPeriod() == AggregationPeriod.DAY then 252 else if GetAggregationPeriod() < AggregationPeriod.WEEK then 50 else if GetAggregationPeriod() < AggregationPeriod.MONTH then 12 else 10;

plot VolumeSpike = isVolumeSpike and Highest(thresholdVolume, maxPeriod) < volume;
VolumeSpike.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
VolumeSpike.SetDefaultColor(Color.LIGHT_ORANGE);

# Truncating volume spikes
def truncatedVolume = if isVolumeSpike and Highest(thresholdVolume,maxPeriod ) < volume then Highest(thresholdVolume, maxPeriod) else volume;

# Plotting truncated volume
plot TruncatedVolumep = truncatedVolume;
#TruncatedVolumep.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TruncatedVolumep.SetDefaultColor(Color.CURRENT);

TruncatedVolumep.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#TruncatedVolumep.SetLineWeight(3);
TruncatedVolumep.DefineColor("Up", Color.UPTICK);
TruncatedVolumep.DefineColor("Down", Color.DOWNTICK);
TruncatedVolumep.DefineColor("Current", Color.CYAN);
TruncatedVolumep.AssignValueColor(if ColorAsPrice then (if close > close[1] then TruncatedVolumep.Color("Up") else if close < close[1] then TruncatedVolumep.Color("Down") else GetColor(1)) else TruncatedVolumep.Color("Current") );

i didn't look over your code yet
take a look at this
https://usethinkscript.com/threads/disproportionate-volume-graph.9534/#post-86698
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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