Need help building a custom watchlist column for HOD

Pyker

New member
So i am looking for help to build a custom watchlist column that shows me when price is struggling with breaking the intraday HOD and keeps rejecting this area over multiple bars. So the watchlist column will paint red when price is within a HOD range, i am thinking HOD +- 1% away from hod price (or possibly 2%) will be good and i only want to see the column paint red when 3 or more bars have rejected this price area. See my attached images for examples of what i mean. So basically, when price is within the box and 3 or more bars have passed, the column turns red and if price goes below the box the column turns black again. Or if the price does breakout of box and make a new HOD, the column will also of course turn black again if/until the same conditions happens again.
So the conditions are,

1. When price is at HOD +- 1%
2. When price has rejected HOD range for 3 or more bars

If possible, it would be useful to know how many bars have passed by adding this number in the column. So for example, if 5 bars have passed, the column will count the bars and say 5.
 

Attachments

  • hod1.png
    hod1.png
    285.2 KB · Views: 186
  • hod2.png
    hod2.png
    288.9 KB · Views: 190
Solution
So i am looking for help to build a custom watchlist column that shows me when price is struggling with breaking the intraday HOD and keeps rejecting this area over multiple bars. So the watchlist column will paint red when price is within a HOD range, i am thinking HOD +- 1% away from hod price (or possibly 2%) will be good and i only want to see the column paint red when 3 or more bars have rejected this price area. See my attached images for examples of what i mean. So basically, when price is within the box and 3 or more bars have passed, the column turns red and if price goes below the box the column turns black again. Or if the price does breakout of box and make a new HOD, the column will also of course turn black again...
So i am looking for help to build a custom watchlist column that shows me when price is struggling with breaking the intraday HOD and keeps rejecting this area over multiple bars. So the watchlist column will paint red when price is within a HOD range, i am thinking HOD +- 1% away from hod price (or possibly 2%) will be good and i only want to see the column paint red when 3 or more bars have rejected this price area. See my attached images for examples of what i mean. So basically, when price is within the box and 3 or more bars have passed, the column turns red and if price goes below the box the column turns black again. Or if the price does breakout of box and make a new HOD, the column will also of course turn black again if/until the same conditions happens again.
So the conditions are,

1. When price is at HOD +- 1%
2. When price has rejected HOD range for 3 or more bars

If possible, it would be useful to know how many bars have passed by adding this number in the column. So for example, if 5 bars have passed, the column will count the bars and say 5.

column study, finds HOD
then determines if high is near the HOD, by x%,
and colors the cells.

price below HOD more than x% = black
first bar within x% of HOD = cyan
after x bars of being near HOD = red
new HOD = green


column study
15minutes

Code:
#z_hod

#col_compare_hod_lower

#https://usethinkscript.com/threads/need-help-building-a-custom-watchlist-column-for-hod.16150/
# a custom watchlist column for HOD

#1. When price is at HOD +- 1%
#2. When price has rejected HOD range for 3 or more bars


def bn = BarNumber();
def na = Double.NaN;

def diffday = GetDay() != GetDay()[1];

input hod_near_percent = 0.4;
input min_near_qty = 3;
input price = high;


def hod = if bn == 1 then high
 else if diffday then high
 else if high > hod[1] then high
 else hod[1];

def hod_near = hod * (1 - (hod_near_percent/100));


#plot z1 = hod;
#plot z2 = hod_near;


def first_near = (price > hod_near and price[1] < hod_near[1]);
def isnear = (price > hod_near and price < hod);
def is_near_qty = (sum(isnear, min_near_qty) >= min_near_qty);

# price below hod more than x% = black
# first bar or first few bars , within x% of hod = cyan 
# after x bars of being near hod = red
# new hod = green

def near_num = if diffday then 0
 else if price < hod_near then 0
 else if is_near_qty then 2
 else if first_near or isnear then 1
 else if price > hod[1] then 3
 else 0;


#plot z = hod_near;
plot z = near_num;
z.setdefaultcolor(color.black);

AssignBackgroundColor(
      if near_num == 0 then color.black
 else if near_num == 1 then color.cyan
 else if near_num == 2 then color.red
 else if near_num == 3 then color.green
 else color.current);
#


column study
color rules
price below hod more than x% = black , 0
first bar within x% of hod = cyan , 1
after x bars of being near hod = red , 2
new hod = green , 3
6atTKSS.jpg



--------------------


upper chart test study
15 minutes

Code:
#col_compare_hod_lower

#https://usethinkscript.com/threads/need-help-building-a-custom-watchlist-column-for-hod.16150/
#Need help building a custom watchlist column for HOD
#Pyker  Aug 5, 2023

#So i am looking for help to build a custom watchlist column that shows me when price is struggling with breaking the intraday HOD and keeps rejecting this area over multiple bars. So the watchlist column will paint red when price is within a HOD range, i am thinking HOD +- 1% away from hod price (or possibly 2%) will be good and i only want to see the column paint red when 3 or more bars have rejected this price area. See my attached images for examples of what i mean. So basically, when price is within the box and 3 or more bars have passed, the column turns red and if price goes below the box the column turns black again. Or if the price does breakout of box and make a new HOD, the column will also of course turn black again if/until the same conditions happens again.

#So the conditions are,
#1. When price is at HOD +- 1%
#2. When price has rejected HOD range for 3 or more bars

#If possible, it would be useful to know how many bars have passed by adding this number in the column. So for example, if 5 bars have passed, the column will count the bars and say 5.



# pick a % to define what is 'close' to hod

# price below hod more than x% = black
# first bar within x% of hod = cyan
# after x bars of being near hod = red
# new hod = green



def bn = BarNumber();
def na = Double.NaN;

def diffday = GetDay() != GetDay()[1];


input hod_near_percent = 0.4;
input min_near_qty = 3;
input price = high;


def hod = if bn == 1 then high
 else if diffday then high
 else if high > hod[1] then high
 else hod[1];

def hod_near = hod * (1 - (hod_near_percent/100));


plot z1 = hod;
plot z2 = hod_near;


def first_near = (price > hod_near and price[1] < hod_near[1]);
def isnear = (price > hod_near and price < hod);
def is_near_qty = (sum(isnear, min_near_qty) >= min_near_qty);

# price below hod more than x% = black
# first bar or first few bars , within x% of hod = cyan 
# after x bars of being near hod = red
# new hod = green

def near_num = if diffday then 0
 else if price < hod_near then 0
 else if is_near_qty then 2
 else if first_near or isnear then 1
 else if price > hod[1] then 3
 else 0;

def vert = 0.0004;
plot z3 = high * (1 + vert);
z3.DefineColor("c0", color.black);
z3.DefineColor("c1", color.cyan);
z3.DefineColor("c2", color.red);
z3.DefineColor("c3", color.green);
z3.AssignValueColor(
      if near_num == 0 then z3.color("c0")
 else if near_num == 1 then z3.color("c1")
 else if near_num == 2 then z3.color("c2")
 else if near_num == 3 then z3.color("c3")
 else color.black);
z3.SetPaintingStrategy(PaintingStrategy.POINTS);
#x.SetDefaultColor(Color.white);
z3.setlineweight(4);
z3.hidebubble();
#


upper chart
PM 15min
top line is HOD
line below hod is the % level, ( default 0.4% )
first 2 bars that are near HOD are cyan
3+ near bars are red
new HOD are green
XHJ5w1u.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
388 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