Range boxes

merc2226

Member
VIP
Can someone help me with this:

At 9:30 am I draw a gray rectangle box starting at 9:30 and ending at 1:00.

I take the market price at 930, the bottom and top of the rectangle is .54 below and above the market price at 930.

I do the exact same thing at 1:00 ending at 4:00

So basically it’s 2 rectangle boxes that create a zone for the morning session and afternoon session.

Can someone help me to code this.

I use it on mobile and TOS.


Something like this? https://usethinkscript.com/threads/levels-tokyo-london-new-york-markets-for-thinkorswim.14520/
Kind of, looks like you have to enter high low area in the code each time or it is using other countries markets to plot on the chart.

The only difference is what i'm looking for it to automatically create the box based on the market price at 9:30 then again at 1:00
high of box and low of box is .54 above and below the market price at 930 and again at 1:00.
It would be a box that is created every day twice a day without me having to do anything.
 
Last edited by a moderator:
Solution
SleepyZ, what can I add to make it start at 9:30 then end and 1:00 while the other one starts at 1:00 and ends at 4:00.

now they both extend across till the end of the day.

This replaces the end times to those you requested

Screenshot 2023-10-28 072409.png
Code:
#Range Boxes

input range_extreme      = .54;
input price              = close;

def range0930 = if SecondsFromTime(1300) > 0
                then Double.NaN
                else if SecondsFromTime(0930)[1] < 0 and SecondsFromTime(0930) >= 0     
                then price
                else range0930[1];

def range1300 = if SecondsFromTime(1600) > 0
                then Double.NaN
                else if SecondsFromTime(1300)[1] < 0 and SecondsFromTime(1300) >= 0
                then...
Can someone help me with this:

At 9:30 am I draw a gray rectangle box starting at 9:30 and ending at 1:00.

I take the market price at 930, the bottom and top of the rectangle is .54 below and above the market price at 930.

I do the exact same thing at 1:00 ending at 4:00

So basically it’s 2 rectangle boxes that create a zone for the morning session and afternoon session.

Can someone help me to code this.

I use it on mobile and TOS.


Something like this? https://usethinkscript.com/threads/levels-tokyo-london-new-york-markets-for-thinkorswim.14520/
Kind of, looks like you have to enter high low area in the code each time or it is using other countries markets to plot on the chart.

The only difference is what i'm looking for it to automatically create the box based on the market price at 9:30 then again at 1:00
high of box and low of box is .54 above and below the market price at 930 and again at 1:00.
It would be a box that is created every day twice a day without me having to do anything.

Various inputs and options to control the output for the range boxes

Screenshot 2023-10-26 092911.png

Code:
#Range Boxes

input range_extreme      = .54;
input range_end_each_day = yes;
input price              = close;

def range0930 = if range_end_each_day and getday()!=getday()[1]
                then double.nan
                else if secondsfromTime(0930)[1] < 0 and secondsfromTime(0930)>=0     
                then price
                else range0930[1];

def range1300 = if range_end_each_day and getday()!=getday()[1]
                then double.nan
                else if secondsfromTime(1300)[1] < 0 and secondsfromTime(1300)>=0
                then price
                else range1300[1];

input hide_lines = no;
plot upper0930 = range0930 + range_extreme;
plot lower0930 = range0930 - range_extreme;

plot upper1300 = range1300 + range_extreme;
plot lower1300 = range1300 - range_extreme;

upper0930.setpaintingStrategy(paintingStrategy.HORIZONTAL);
lower0930.setpaintingStrategy(paintingStrategy.HORIZONTAL);
upper1300.setpaintingStrategy(paintingStrategy.HORIZONTAL);
lower1300.setpaintingStrategy(paintingStrategy.HORIZONTAL);

defineGlobalColor("Lines", color.gray);
upper0930.setdefaultColor(globalColor("Lines"));
lower0930.setdefaultColor(globalColor("Lines"));
upper1300.setdefaultColor(globalColor("Lines"));
lower1300.setdefaultColor(globalColor("Lines"));

upper0930.sethiding(hide_lines);
lower0930.sethiding(hide_lines);
upper1300.sethiding(hide_lines);
lower1300.sethiding(hide_lines);


input clouds = yes;
defineGlobalColor("0930", color.light_green);
defineGlobalColor("1300", color.light_gray);

addcloud(if clouds then upper0930 else double.nan, lower0930, globalColor("0930"), globalColor("0930"));
addcloud(if clouds then upper1300 else double.nan, lower1300, globalColor("1300"), globalColor("1300"));

#
 

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

SleepyZ, what can I add to make it start at 9:30 then end and 1:00 while the other one starts at 1:00 and ends at 4:00.

now they both extend across till the end of the day.

This replaces the end times to those you requested

Screenshot 2023-10-28 072409.png
Code:
#Range Boxes

input range_extreme      = .54;
input price              = close;

def range0930 = if SecondsFromTime(1300) > 0
                then Double.NaN
                else if SecondsFromTime(0930)[1] < 0 and SecondsFromTime(0930) >= 0     
                then price
                else range0930[1];

def range1300 = if SecondsFromTime(1600) > 0
                then Double.NaN
                else if SecondsFromTime(1300)[1] < 0 and SecondsFromTime(1300) >= 0
                then price
                else range1300[1];

input hide_lines = no;
plot upper0930 = range0930 + range_extreme;
plot lower0930 = range0930 - range_extreme;

plot upper1300 = range1300 + range_extreme;
plot lower1300 = range1300 - range_extreme;

upper0930.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lower0930.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
upper1300.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lower1300.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

DefineGlobalColor("Lines", Color.GRAY);
upper0930.SetDefaultColor(GlobalColor("Lines"));
lower0930.SetDefaultColor(GlobalColor("Lines"));
upper1300.SetDefaultColor(GlobalColor("Lines"));
lower1300.SetDefaultColor(GlobalColor("Lines"));

upper0930.SetHiding(hide_lines);
lower0930.SetHiding(hide_lines);
upper1300.SetHiding(hide_lines);
lower1300.SetHiding(hide_lines);


input clouds = yes;
DefineGlobalColor("0930", Color.LIGHT_GREEN);
DefineGlobalColor("1300", Color.LIGHT_GRAY);

AddCloud(if clouds then upper0930 else Double.NaN, lower0930, GlobalColor("0930"), GlobalColor("0930"));
AddCloud(if clouds then upper1300 else Double.NaN, lower1300, GlobalColor("1300"), GlobalColor("1300"));

#
 
Solution
Can someone help me with this:

At 9:30 am I draw a gray rectangle box starting at 9:30 and ending at 1:00.

I take the market price at 930, the bottom and top of the rectangle is .54 below and above the market price at 930.

I do the exact same thing at 1:00 ending at 4:00

So basically it’s 2 rectangle boxes that create a zone for the morning session and afternoon session.

Can someone help me to code this.

I use it on mobile and TOS.


Something like this? https://usethinkscript.com/threads/levels-tokyo-london-new-york-markets-for-thinkorswim.14520/
Kind of, looks like you have to enter high low area in the code each time or it is using other countries markets to plot on the chart.

The only difference is what i'm looking for it to automatically create the box based on the market price at 9:30 then again at 1:00
high of box and low of box is .54 above and below the market price at 930 and again at 1:00.
It would be a box that is created every day twice a day without me having to do anything.
Have you resolved it?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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