Plot second highest

tatl

Member
I need a way to get the highest, second highest, third highest, fourth highest, etc of a variable. let's say its volume for simplicity.
 
Last edited by a moderator:
Solution
I need a way to get the highest, second highest, third highest, fourth highest, etc of a variable. let's say its volume for simplicity.


find the nth highest volume.
can pick a ranking of 1 to 5.
draws a triangle on nth volume bar
can draw a horizontal line at the volume level


Code:
# xth_highest_vol_00

#https://usethinkscript.com/threads/plot-second-highest.14951/
#Plot second highest

def na = double.nan;
def bn = barnumber();

def v = volume;

input nth_highest_vol = 2;
#hint nth_highest_vol: Enter a number 1 to 5 , to find the nth highest volume

def hi1 = HighestAll(v);
def hi2 = HighestAll(if v < hi1 then v else 0);
def hi3 = HighestAll(if v < hi2 then v else 0);
def hi4 = HighestAll(if v < hi3 then v else 0);
def hi5 =...
I need a way to get the highest, second highest, third highest, fourth highest, etc of a variable. let's say its volume for simplicity.


find the nth highest volume.
can pick a ranking of 1 to 5.
draws a triangle on nth volume bar
can draw a horizontal line at the volume level


Code:
# xth_highest_vol_00

#https://usethinkscript.com/threads/plot-second-highest.14951/
#Plot second highest

def na = double.nan;
def bn = barnumber();

def v = volume;

input nth_highest_vol = 2;
#hint nth_highest_vol: Enter a number 1 to 5 , to find the nth highest volume

def hi1 = HighestAll(v);
def hi2 = HighestAll(if v < hi1 then v else 0);
def hi3 = HighestAll(if v < hi2 then v else 0);
def hi4 = HighestAll(if v < hi3 then v else 0);
def hi5 = HighestAll(if v < hi4 then v else 0);


def vx = if nth_highest_vol == 1 then hi1
 else if nth_highest_vol == 2 then hi2
 else if nth_highest_vol == 3 then hi3
 else if nth_highest_vol == 4 then hi4
 else if nth_highest_vol == 5 then hi5
 else 0;

plot vz = if vx == v then v else na;
vz.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
vz.SetDefaultColor(Color.yellow);
vz.setlineweight(3);
vz.hidebubble();

input show_horz_line = yes;
plot zline = if show_horz_line then vx else na;
zline.SetDefaultColor(Color.yellow);
zline.hidebubble();

#

set to 4, find the 4th highest volume
draw a line at that volume level
ZL3wl7B.jpg
 
Solution

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
571 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