first 5 min highest and lowest price

vantduong

Member
VIP
I want to get the highest and lowest price (H and L) of the first 5 minutes after opening market then draw the HORIZONTAL with any lower time frame such as 1 minutes.
can we get the highest and lowest price (H and L) of the first 5 minutes after opening market and draw the HORIZONTAL line with this code. No matter what frame time we use. Thank you

H.setpaintingStrategy(paintingStrategy.HORIZONTAL);
H.setdefaultColor(color.green);

L.setpaintingStrategy(paintingStrategy.HORIZONTAL);
L.setdefaultColor(color.red);
 
Last edited:
Solution
I just need to draw the line in Highest and lowest for the first 5 minutes to use my own strategy. But the ORG is very helpful . Thank you anyway

See if this helps. It should draw the lines starting at the market open and expand during the 1st 5 minutes and then extend the lines until the next marrket open

Screenshot 2024-01-22 065531.png
Code:
#HL_TimeRange_using_ProfileHL

input begin = 0930;
input end   = 0935;

input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE};
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
}

def rth  = if isnan(close) then rth[1] else SecondsFromTime(begin) >= 0 and SecondsTillTime(end) > 0;
def cond = rth != rth[1]...
I want to get the highest and lowest price (H and L) of the first 5 minutes after opening market then draw the HORIZONTAL with any lower time frame such as 1 minutes.
can we get the highest and lowest price (H and L) of the first 5 minutes after opening market and draw the HORIZONTAL line with this code. No matter what frame time we use. Thank you

H.setpaintingStrategy(paintingStrategy.HORIZONTAL);
H.setdefaultColor(color.green);

L.setpaintingStrategy(paintingStrategy.HORIZONTAL);
L.setdefaultColor(color.red);

what you are asking for is ORB, opening range breakout
here are a couple
https://usethinkscript.com/threads/opening-range-breakout-indicator-for-thinkorswim.16/

https://usethinkscript.com/threads/orb-difference.16512/#post-131174
 

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

I just need to draw the line in Highest and lowest for the first 5 minutes to use my own strategy. But the ORG is very helpful . Thank you anyway

See if this helps. It should draw the lines starting at the market open and expand during the 1st 5 minutes and then extend the lines until the next marrket open

Screenshot 2024-01-22 065531.png
Code:
#HL_TimeRange_using_ProfileHL

input begin = 0930;
input end   = 0935;

input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE};
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
}

def rth  = if isnan(close) then rth[1] else SecondsFromTime(begin) >= 0 and SecondsTillTime(end) > 0;
def cond = rth != rth[1];

profile vol = VolumeProfile("startNewProfile" = cond and secondstilltime(end)>=0, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);


profile vol1 = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);


def hProfile = if IsNaN(vol.GetHighest()) then hProfile[1] else vol1.GetHighest();
def lProfile = if IsNaN(vol.GetLowest())  then lProfile[1] else vol1.GetLowest();
def uprof    = if !rth or IsNaN(close) then uprof[1] else hProfile;
def lprof    = if !rth or IsNaN(close) then lprof[1] else lProfile;

plot ProfileHigh =  uprof;
plot ProfileLow  =  lprof;

ProfileHigh.SetDefaultColor(Color.GREEN);
ProfileLow.SetDefaultColor(Color.RED);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Solution
OR5MinutesMine.jpg
I am very newbie. Thanks for all of you here support me every time I asked
I use this code . It seem work well. I want to share if anything not correct please advice.

#DTVAN

def agg5 = AggregationPeriod.FIVE_MIN;

input startTimeMarket = 0930;
input endTimeFirst5Minute = 0935;

def startCounter5 = SecondsFromTime(startTimeMarket);
def endCounter5 = SecondsTillTime(endTimeFirst5Minute);
def first5Minutes = if startCounter5 >= 0 and endCounter5 > 0 then 1 else 0;

def high5 = if first5Minutes and !first5Minutes[1]
then high(period = agg5)
else if first5Minutes then if high > high5[1] then high else high5[1]
else high5[1];

def low5 = if first5Minutes and !first5Minutes[1]
then low(period = agg5)
else if first5Minutes then if low < low5[1] then low else low5[1]
else low5[1];

#END DTVAN

AddLabel (yes, "H5 :" + high5, Color.GREEN);
AddLabel (yes, "L5 :" + low5, Color.WHITE);

plot H5 = high5;
H5.setpaintingStrategy(paintingStrategy.HORIZONTAL);
H5.setdefaultColor(color.yellow);


plot L5 = low5;
L5.setpaintingStrategy(paintingStrategy.HORIZONTAL);
L5.setdefaultColor(color.yellow);
 
View attachment 20770I am very newbie. Thanks for all of you here support me every time I asked
I use this code . It seem work well. I want to share if anything not correct please advice.

#DTVAN

def agg5 = AggregationPeriod.FIVE_MIN;

input startTimeMarket = 0930;
input endTimeFirst5Minute = 0935;

def startCounter5 = SecondsFromTime(startTimeMarket);
def endCounter5 = SecondsTillTime(endTimeFirst5Minute);
def first5Minutes = if startCounter5 >= 0 and endCounter5 > 0 then 1 else 0;

def high5 = if first5Minutes and !first5Minutes[1]
then high(period = agg5)
else if first5Minutes then if high > high5[1] then high else high5[1]
else high5[1];

def low5 = if first5Minutes and !first5Minutes[1]
then low(period = agg5)
else if first5Minutes then if low < low5[1] then low else low5[1]
else low5[1];

#END DTVAN

AddLabel (yes, "H5 :" + high5, Color.GREEN);
AddLabel (yes, "L5 :" + low5, Color.WHITE);

plot H5 = high5;
H5.setpaintingStrategy(paintingStrategy.HORIZONTAL);
H5.setdefaultColor(color.yellow);


plot L5 = low5;
L5.setpaintingStrategy(paintingStrategy.HORIZONTAL);
L5.setdefaultColor(color.yellow);

Your code seems to work very well. Nice work!!
 
Here is the code loaded from what I provided in post #4 above in the following link https://tos.mx/b5QHS51. It works as shown in the image below

If you are still having problems, plost a link to the chart and share it.
Thank you. I checked the link you share the code is the same. But it worked very well. after investigating. I found out the reason is the code if i place in tab STRATEGY it not work well. But if i place in Tab STUDY It work well.
Any one have any idea about that?
 
Thank you. I checked the link you share the code is the same. But it worked very well. after investigating. I found out the reason is the code if i place in tab STRATEGY it not work well. But if i place in Tab STUDY It work well.
Any one have any idea about that?
The strategy tab is ONLY for scripts utilizing ADDORDER statements for the backtesting process.
Studies can only be cut and pasted into the study tab.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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