High and low after a particular price

kvr53

New member
How do I make a chart label to show intraday high and low after a certain price first occurs ?

For example, stock A reaches $10 at 9:45, this label would show stock A's highest high and lowest low after being traded at $10 (from 9:30 to 15:59)
 
Solution
How do I make a chart label to show intraday high and low after a certain price first occurs ?

For example, stock A reaches $10 at 9:45, this label would show stock A's highest high and lowest low after being traded at $10 (from 9:30 to 15:59)

As the developing HOD occurs, then this code from the first HOD and thereafter, will find the subsequent HH/LL until a nwe higher HOD occurs.

Capture.jpg
Ruby:
#HHLL_PullBack_After_Developing_HODs

input showlabel_HH       = yes;
input showlabel_First_HH = yes;
#Time Defined
input timezone = {default "ET", "CT", "MT", "PT"};

def starthour  = (if timezone == timezone."ET"
                        then 9
                        else if timezone == timezone."CT"
                        then...
How do I make a chart label to show intraday high and low after a certain price first occurs ?

For example, stock A reaches $10 at 9:45, this label would show stock A's highest high and lowest low after being traded at $10 (from 9:30 to 15:59)

As the developing HOD occurs, then this code from the first HOD and thereafter, will find the subsequent HH/LL until a nwe higher HOD occurs.

Capture.jpg
Ruby:
#HHLL_PullBack_After_Developing_HODs

input showlabel_HH       = yes;
input showlabel_First_HH = yes;
#Time Defined
input timezone = {default "ET", "CT", "MT", "PT"};

def starthour  = (if timezone == timezone."ET"
                        then 9
                        else if timezone == timezone."CT"
                        then 8
                        else if timezone == timezone."MT"
                        then 7
                        else 6) ;

def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);

def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60;

#Highest High during RTH
plot bn  = BarNumber();
#bn.setpaintingStrategy(paintingStrategy.VALUES_BELOW);
def rth = Between(GetTime(), RegularTradingStart(GetYYYYMMDD()), RegularTradingEnd(GetYYYYMMDD()));

def multihighs = if GetDay() == GetLastDay() and rth
                 then if high == high(period = AggregationPeriod.DAY)
                      then multihighs[1] + 1
                      else multihighs[1]
                 else 0;

def firsthibn    = if multihighs[1] == 0 and multihighs == 1
                   then bn
                   else firsthibn[1];

def hihr    = if bn == HighestAll(firsthibn) then hour else hihr[1];
def himin   = if bn == HighestAll(firsthibn) then minutes else himin[1];
def dh      = if bn == HighestAll(firsthibn) then high else dh[1];

AddLabel(showlabel_HH, "DH@ " +
           ((hihr + ":") +
           (if himin < 10
            then "0" + himin
            else  "" + himin))
            + " ; " + dh, Color.GREEN);


def nexthh = if GetDay() == GetLastDay() and rth and bn > HighestAll(firsthibn)
             then Max(high, nexthh[1])
             else nexthh[1];
AddLabel(1, "HH after DH: " + HighestAll(nexthh), Color.LIGHT_GREEN);

def nextll = CompoundValue(1,
             if GetDay() == GetLastDay() and rth and bn == HighestAll(firsthibn)
             then low
             else if bn > HighestAll(firsthibn)
             then Min(low, nextll[1])
             else nextll[1], low);

AddLabel(1, "LL after DH: " + (nextll), Color.LIGHT_RED);
#
 
Solution
As the developing HOD occurs, then this code from the first HOD and thereafter, will find the subsequent HH/LL until a nwe higher HOD occurs.
The above code is for a live session. I actually would use such label after a trading session is finished. I manually enter the price, then it shows me relevant values.

In my previous example, I would enter $10 to input, and the label would show me highest high and lowest low after stock A being firstly traded at $10 in the ended session
 
The above code is for a live session. I actually would use such label after a trading session is finished. I manually enter the price, then it shows me relevant values.

In my previous example, I would enter $10 to input, and the label would show me highest high and lowest low after stock A being firstly traded at $10 in the ended session
You could try using the code for 30 bars I provided and leave the debug on to find the bar/count that has the price you want to use
 
You could try using the code for 30 bars I provided and leave the debug on to find the bar/count that has the price you want to use
Yeah, saw you post about that. it's a bit different in this case. I figure it's better to input a price rather than a bar, because if the highest high or lowest low occur in that same beginning bar (30th bar), it's gonna skip it. whereas high and low after a certain price point leave out the concept of 'Bars', so won't have that problem.
 
Hi Guys, i want to plot a label for high/low of the day time only. is there any study available for High low time for the day?

See if this provides what you can use

Capture.jpg
Ruby:
input timezone = {default "ET", "CT", "MT", "PT"};

def starthour  = (if timezone == timezone."ET"
                        then 9
                        else if timezone == timezone."CT"
                        then 8
                        else if timezone == timezone."MT"
                        then 7
                        else 6) ;
def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);
def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60;

#Highest High during RTH
def begin      = CompoundValue(1, if gettime() crosses above regularTradingStart(getyyyYMMDD())
                                       then high
                                       else if high > begin[1]
                                       then high
                                       else begin[1]
                                  , begin[1]);
def beginbn    = if GetDay() == GetLastDay()
                 then if high == begin
                      then BarNumber()
                      else beginbn[1]
                 else 0;
def highday    = if BarNumber() == HighestAll(beginbn)
                 then high
                 else highday[1];

plot hdcross = if high == highday then high else Double.NaN;
hdcross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
def hihr    = if  high == highday then hour else hihr[1];
def himin   = if  high == highday then minutes else himin[1];
AddLabel(1, "H: " +(hihr + ":") +
           (if himin < 10
            then "0" + himin + " - " + highday
            else  "" + himin + " - " + highday) , Color.WHITE);

#Lowest Low During RTH
def begin1 = CompoundValue(1,  if gettime() crosses above regularTradingStart(getyyyYMMDD())
                               then low
                               else if low < begin1[1]
                               then low
                               else begin1[1],
                              low);
def beginbn1    = if GetDay() == GetLastDay()
                  then if low == begin1
                       then BarNumber()
                       else beginbn1[1]
                  else 0;
def lowday     = if BarNumber() == HighestAll(beginbn1)
                 then low
                 else lowday[1];

plot ldcross = if low == lowday then low else Double.NaN;
def lowhr    = if low == lowday then hour else lowhr[1];
def lowmin   = if low == lowday then minutes else lowmin[1];
AddLabel(1, "L: " + " " +
           (lowhr + ":") +
           (if lowmin < 10
            then "0" + lowmin + " - " + lowday
            else  "" + lowmin + " - " + lowday) , Color.WHITE);

plot hd = highday;
hd.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot ld = lowday;
ld.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

input bubbles = yes;
AddChartBubble(bubbles and !IsNaN(hour) and IsNaN(hdcross[1]) and hdcross, high,
               hour  + ":" + if minutes < 10
                              then "0" + minutes + " - " + hd
                              else "" + minutes + " - " + hd, Color.WHITE, yes);

AddChartBubble(bubbles and !IsNaN(hour) and IsNaN(ldcross[1]) and ldcross, low,
               hour + ":" + if minutes < 10
                              then "0" + minutes + " - " + ld
                              else "" + minutes + " - " + ld, Color.WHITE, no);
 
Thank you, yes it worked and i created a watchlist column for it but now i want to only list high + time within first 2 hours and if high was formed within first 2 hour (after market open) whats the low time and price after that high? i have been tweeting the code for it but i cant figure it out. i set the time for first 2 hours as test but problem is that its reporting low before the high. i know it can be done by complex if/then/else statement but i kinda newbie at thinkscript.


here is the screenshot of watchlisthttps://ibb.co/2PCY2xx
 
here is the modified script for High time and price

#Change Hours_Offset in the input to HRS you need to adjust for daylight savings or your local timezone
input Hours_Offset = 0;
input Start = 8.5;
input End = 10.49;

def h = high;
def l = low;
def c = close;
def x = BarNumber();
def D = 86400;
def Hr = 3600;
def epoch = (GetTime() / 1000);
def hour = ((epoch % D) / Hr); # 5 hour diff for GMT
def roll = if hour > 5 then hour - 5 else if hour < 5
then (hour + 24) - 5 else 0;
def min = Floor(((epoch % D) % Hr)) / 60;
def RTH_HOD = if roll crosses above Start then h else if Between(roll, Start, End) then Max(h, RTH_HOD[1]) else RTH_HOD[1];
def RTH_LOD = if roll crosses above Start then l else if Between(roll, Start, End) then Min(l, RTH_LOD[1]) else RTH_LOD[1];



def HODx;
def HODHr;
def HODmin;
if RTH_HOD == h
{ HODx = x;
HODHr = roll;
HODmin = min; }
else
{ HODx = HODx[1];
HODHr = HODHr[1];
HODmin = HODmin[1];}


def LODx;
def LODHr;
def LODmin;
if RTH_LOD == l
{ LODx = x;
LODHr = roll;
LODmin = min; }
else
{ LODx = LODx[1];
LODHr = LODHr[1];
LODmin = LODmin[1];}



#AddLabel (yes, if LODmin > 9 then "LOD " + (RTH_LOD) + " @" + Floor(LODHr + Hours_Offset) + ":" + LODmin + "AM" else "LOD" + (RTH_LOD) + " @" + Floor(LODHr + Hours_Offset) + ":0" + LODmin + "PM" );



#AddLabel (yes, if HODmin > 8.5 then "" + Floor(HODHr + Hours_Offset)
#+ ":" + HODmin else "" + Floor(HODHr + Hours_Offset)
#+ ":0" + HODmin);



AddLabel (yes, if HODmin > 8 then (RTH_HOD)
  • " " + Floor(HODHr + Hours_Offset)
  • ":" + HODmin
else + (RTH_HOD)
  • " " + floor(HODHr + Hours_Offset)
  • ":0"
  • HODmin
);
 

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