Highest Volume of the year

ktraders

New member
Hello,
Appreciate if someone can help with the below thinkscript. I am looking to show a plot on the chart on the day / bar of the highest volume of the past year. This script displays more than one day in the past year or sometimes doesn't display the plot at all .

def IsDaily = GetAggregationPeriod() == AggregationPeriod.DAY ;
def IsWeekly = GetAggregationPeriod() == AggregationPeriod.WEEK;
def Ismonthly = GetAggregationPeriod() == AggregationPeriod.MONTH ;

def length = if IsDaily then 252 else if IsWeekly then 52 else if Ismonthly then 12 else Double.NaN;
def highvol = Highest(volume, length);

plot top = if volume == highvol then 1 else Double.NaN;

top.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
top.SetDefaultColor(color.WHITE);
 
Solution
This below code seems to solve the problem:

def IsDaily = GetAggregationPeriod() == AggregationPeriod.DAY ;
def IsWeekly = GetAggregationPeriod() == AggregationPeriod.WEEK;
def Ismonthly = GetAggregationPeriod() == AggregationPeriod.MONTH ;
def length = if IsDaily then 252 else if IsWeekly then 52 else if Ismonthly then 12 else Double.NaN;

#def LastBar = HighestAll(if isNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN);
#def BarCD = LastBar - BarNumber() <= Length;
#def HighVol = HighestAll(if BarCD then Volume else Double.nan);
def highvol = HighestAll(volume);
#plot VolLine = if BarCD then HighVol else Double.nan;

plot top = if volume == highvol then volume else Double.NaN...
Ruby:
def IsDaily = GetAggregationPeriod() == AggregationPeriod.DAY ;
def IsWeekly = GetAggregationPeriod() == AggregationPeriod.WEEK;
def Ismonthly = GetAggregationPeriod() == AggregationPeriod.MONTH ;
def length = if IsDaily then 252 else if IsWeekly then 52 else if Ismonthly then 12 else Double.NaN;
#
def LastBar =
    HighestAll(if isNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN)
;
def BarCD =
    LastBar - BarNumber() <= Length
;
def HighVol =
    HighestAll(if BarCD then Volume else Double.nan)
;
plot VolLine =
    if BarCD then HighVol else Double.nan
;
#
plot top = if volume == highvol then volume else Double.NaN;
top.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
top.SetDefaultColor(color.WHITE);
top.setlineWeight(5);
 
Ruby:
def IsDaily = GetAggregationPeriod() == AggregationPeriod.DAY ;
def IsWeekly = GetAggregationPeriod() == AggregationPeriod.WEEK;
def Ismonthly = GetAggregationPeriod() == AggregationPeriod.MONTH ;
def length = if IsDaily then 252 else if IsWeekly then 52 else if Ismonthly then 12 else Double.NaN;
#
def LastBar =
    HighestAll(if isNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN)
;
def BarCD =
    LastBar - BarNumber() <= Length
;
def HighVol =
    HighestAll(if BarCD then Volume else Double.nan)
;
plot VolLine =
    if BarCD then HighVol else Double.nan
;
#
plot top = if volume == highvol then volume else Double.NaN;
top.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
top.SetDefaultColor(color.WHITE);
top.setlineWeight(5);
Thanks for the help Joshua, but unfortunately this renders the chart unusable. I am unable to see the bars / candles.https%3A//i.imgur.com/kbPI6BG.png[/img]']
kbPI6BG.png
 
Last edited:
Im posting from my phone at the moment, what am I looking at here, I can't see it? Is your volume overlayed in the price chart?

Try putting the volume in it's own panel and make sure the code is on the volume section in edit studies and tell me what happens.
 
Last edited:
Hello,
Appreciate if someone can help with the below thinkscript. I am looking to show a plot on the chart on the day / bar of the highest volume of the past year. This script displays more than one day in the past year or sometimes doesn't display the plot at all .

def IsDaily = GetAggregationPeriod() == AggregationPeriod.DAY ;
def IsWeekly = GetAggregationPeriod() == AggregationPeriod.WEEK;
def Ismonthly = GetAggregationPeriod() == AggregationPeriod.MONTH ;

def length = if IsDaily then 252 else if IsWeekly then 52 else if Ismonthly then 12 else Double.NaN;
def highvol = Highest(volume, length);

plot top = if volume == highvol then 1 else Double.NaN;

top.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
top.SetDefaultColor(color.WHITE);
https://tos.mx/X8DGDT This may help, volume indicator showing total, buy, and sell volumes as a histogram. Also average volume as a line plot. Bars with a specified percent over the average volume are marked on the bar. Additional Volume information provided by labels.
 
This below code seems to solve the problem:

def IsDaily = GetAggregationPeriod() == AggregationPeriod.DAY ;
def IsWeekly = GetAggregationPeriod() == AggregationPeriod.WEEK;
def Ismonthly = GetAggregationPeriod() == AggregationPeriod.MONTH ;
def length = if IsDaily then 252 else if IsWeekly then 52 else if Ismonthly then 12 else Double.NaN;

#def LastBar = HighestAll(if isNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN);
#def BarCD = LastBar - BarNumber() <= Length;
#def HighVol = HighestAll(if BarCD then Volume else Double.nan);
def highvol = HighestAll(volume);
#plot VolLine = if BarCD then HighVol else Double.nan;

plot top = if volume == highvol then volume else Double.NaN;
top.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
top.SetDefaultColor(color.WHITE);
top.setlineWeight(5);
 
Solution
That will work assuming you have only one years worth of data on the chart. Otherwise, it will show you the highest volume for how ever far back the chart goes.
 
Ok, so I am home now and at an actual computer.

Change this line:

Code:
def BarCD =
    LastBar - BarNumber() <= Length
;

to

Code:
def BarCD =
    LastBar - BarNumber() + 1 <= Length
;

The start of the year was off by one bar if you want to get really specific, but that is not the problem, in fact, what is the problem? That is the highest volume in the last years worth of data, is it not?

EO9L7fB.png
 
Ok, so I am home now and at an actual computer.

Change this line:

Code:
def BarCD =
    LastBar - BarNumber() <= Length
;

to

Code:
def BarCD =
    LastBar - BarNumber() + 1 <= Length
;

The start of the year was off by one bar if you want to get really specific, but that is not the problem, in fact, what is the problem? That is the highest volume in the last years worth of data, is it not?

EO9L7fB.png
I do appreciate you getting back to me, but this too doesn't solve the problem as you can see we don't see the candlestick chart. I want to be able to see the chart as well as have a plot shown on it signifying the day of the highest volume to drawn my eye to it while studying the chart.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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