Resize VolumeAVG To Prevent Overlap w/ Price For ThinkOrSwim

KDM82

New member
Hello. New to the community!! I'm wondering if it's possible to resize the VolumeAVG study when placing it on the Price chart? Reason I would like to do this is so there is little to no overlap on the price candles. I'd like the study to be anchored to the bottom of the price chart & have the tops of the volume bars no higher than 15-20% from the bottom of the price chart. I also remove the moving average plot from this study so its just the volume bars... Is something like this possible with thinkScript? Or maybe something like this is available already to the community? Appreciate anyones help. Cheers!!
 
Hello. New to the community!! I'm wondering if it's possible to resize the VolumeAVG study when placing it on the Price chart? Reason I would like to do this is so there is little to no overlap on the price candles. I'd like the study to be anchored to the bottom of the price chart & have the tops of the volume bars no higher than 15-20% from the bottom of the price chart. I also remove the moving average plot from this study so its just the volume bars... Is something like this possible with thinkScript? Or maybe something like this is available already to the community? Appreciate anyones help. Cheers!!

hello and welcome

here is one way,
this draws volume bars on the main chart.

it finds the price range of price bars,
pick 2 percentages, for height and bottom of bars,
then scale the volume bars


this determines the height of volume bars, a % of the price range of candles, lowest to highest.
..input vol_ht_per_of_prices = 25;

this determines the base of volume bars, a % of the price range of candles, lowest to highest.
this price number is subtracted from the lowest price level.
..input vol_per_pos_from_price_lowest = -30;
...if set to 50, it would put the bottom of volume bars in the middle of the chart.


Code:
# vol_bars_on_main_00

# https://usethinkscript.com/threads/resize-volumeavg-to-prevent-overlap-w-price-for-thinkorswim.13212/
# Resize VolumeAVG study on Price chart

def bn = barnumber();
def na = double.nan;
def iscls = !isnan(close);

#input averagetype = averagetype.simple;
#input length = 5;
#def avg = movingaverage(averagetype, close, length);

def hihi = highestall(high);
def lolo = lowestall(low);
def hilorng = hihi - lolo;

input vol_ht_per_of_prices = 25;
input vol_per_pos_from_price_lowest = -30;

def vol_ht = hilorng * (vol_ht_per_of_prices/100);
def vol_base = lolo + (hilorng * (vol_per_pos_from_price_lowest/100));
def vol_top = vol_base + vol_ht;

input show_line_levels = no;

plot zh = if iscls then hihi else na;
plot zl = if iscls then lolo else na;
plot zv2 = if iscls then vol_top else na;
plot zv1 = if iscls then vol_base else na;

zh.SetHiding(!show_line_levels);
zl.SetHiding(!show_line_levels);
zv2.SetHiding(!show_line_levels);
zv1.SetHiding(!show_line_levels);

zh.SetDefaultColor(Color.gray);
zl.SetDefaultColor(Color.gray);
zv2.SetDefaultColor(Color.cyan);
zv1.SetDefaultColor(Color.white);

# x.setlineweight(1);
# x.hidebubble();

#------------------------------

def v = volume;
def vol_max = highestall(v);
def vol_adj_top = vol_base + (vol_ht * (v/vol_max));
def vol_adj_bot = vol_base;

def c = vol_adj_bot;
def o = vol_adj_top;
def l = c;
def h = o;

AddChart(high = h, low = l, open = o, close = c, growcolor = color.blue, fallcolor = color.yellow, type = ChartType.CANDLE);
#

in this image, i have lines turned on, that define the price range highest and lowest, and the range of volume bars

pMkX99S.jpg
 
Last edited by a moderator:

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
614 Online
Create Post

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