How to Draw a Rectangle Box in ThinkorSwim

Stewart

New member
Is there a script for me to draw in my own Supply and Demand Zones? Not automated by the computer.

I know I can draw a box, but I would like to be able to make a rectangle around one or 2 bars, then have that rectangle go on into infinity to the right. It seems simple. Has anyone done this? It would be nice if the box would show the price range and maybe have the supply zone be one color and the demand zone a different color.

Any help would be appreciated.

Thank You
 

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

Thank you. I understand there is a rectangle.
But I would like to draw the rectangle over one or 2 bars and have the computer automatically extend the bar all the way to the right of the screen.

I’m looking at zones that may have started many bars ago.

Can that basic rectangle be modified to do that?
 
@Stewart Ahh, got it. I don't think that's possible. You will have to manually extend the rectangle.

Your existing rectangle draw can be modified manually.
 
@Stewart You can do this in a somewhat tedious way. Draw your box. Left click on the box. Edit Properties. Change the date for one of the lower box to the date you wish to extend till. The box will then expand to that date.
 
Hi, I have started to write this script that plots rectangular boxes on the chart and it works but I want it to show only on the current intraday chart. As is stands now, if you scroll back it shows on previous days. I can't seem to figure this out. Does anyone know what I need to do to correct this problem? I would really appreciate any help, thanks! I have included the script below:

Code:
Created 4-13-21 by TCB

input ShowTodayOnly={"No", default "Yes"};
input alertPeriodStart = 930;
input alertPeriodEnd = 1130;
def Today = if GetLastDay() == GetDay() then 1 else 0;
def StartAlertPeriod = SecondsTillTime(alertPeriodStart);
def EndAlertPeriod = SecondsTillTime(alertPeriodEnd);
def AlertPeriod = If (StartAlertPeriod <= 0 and EndAlertPeriod > 0, close, 0);

input PutLevelStart = 0.0;
input CallLevelStart = 0.0;
input Range = 0.0;

input HideBoxLines = Yes;
input HideLabels = Yes;

def PutTopBox = PutLevelStart + Range;
def CallBottomBox = CallLevelStart - Range;

plot TopArea = HighestAll (if AlertPeriod then PutTopBox else Double.NaN);
TopArea.SetDefaultColor(Color.GRAY);
TopArea.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TopArea.SetHiding(HideBoxLines);

plot BottomArea = HighestAll (if AlertPeriod then CallBottomBox else Double.NaN);
BottomArea.SetDefaultColor(Color.GRAY);
BottomArea.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
BottomArea.SetHiding(HideBoxLines);

plot PutBBox = LowestAll (if AlertPeriod then PutLevelStart else Double.NaN);
PutBBox.SetDefaultColor(Color.GRAY);
PutBBox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PutBBox.SetHiding(HideBoxLines);

plot CallTBox = HighestAll (if AlertPeriod then CallLevelStart else Double.NaN);
CallTBox.SetDefaultColor(Color.GRAY);
CallTBox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
CallTBox.SetHiding(HideBoxLines);

AddCloud(if AlertPeriod then TopArea else Double.NaN, if AlertPeriod then PutBBox else Double.NaN, Color.GRAY, Color.GRAY);
AddCloud(if AlertPeriod then BottomArea else Double.NaN, if AlertPeriod then CallTBox else Double.NaN, Color.GRAY, Color.GRAY);
 
Hi, I have started to write this script that plots rectangular boxes on the chart and it works but I want it to show only on the current intraday chart. As is stands now, if you scroll back it shows on previous days. I can't seem to figure this out. Does anyone know what I need to do to correct this problem? I would really appreciate any help, thanks! I have included the script below:

Code:
Created 4-13-21 by TCB

input ShowTodayOnly={"No", default "Yes"};
input alertPeriodStart = 930;
input alertPeriodEnd = 1130;
def Today = if GetLastDay() == GetDay() then 1 else 0;
def StartAlertPeriod = SecondsTillTime(alertPeriodStart);
def EndAlertPeriod = SecondsTillTime(alertPeriodEnd);
def AlertPeriod = If (StartAlertPeriod <= 0 and EndAlertPeriod > 0, close, 0);

input PutLevelStart = 0.0;
input CallLevelStart = 0.0;
input Range = 0.0;

input HideBoxLines = Yes;
input HideLabels = Yes;

def PutTopBox = PutLevelStart + Range;
def CallBottomBox = CallLevelStart - Range;

plot TopArea = HighestAll (if AlertPeriod then PutTopBox else Double.NaN);
TopArea.SetDefaultColor(Color.GRAY);
TopArea.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TopArea.SetHiding(HideBoxLines);

plot BottomArea = HighestAll (if AlertPeriod then CallBottomBox else Double.NaN);
BottomArea.SetDefaultColor(Color.GRAY);
BottomArea.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
BottomArea.SetHiding(HideBoxLines);

plot PutBBox = LowestAll (if AlertPeriod then PutLevelStart else Double.NaN);
PutBBox.SetDefaultColor(Color.GRAY);
PutBBox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PutBBox.SetHiding(HideBoxLines);

plot CallTBox = HighestAll (if AlertPeriod then CallLevelStart else Double.NaN);
CallTBox.SetDefaultColor(Color.GRAY);
CallTBox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
CallTBox.SetHiding(HideBoxLines);

AddCloud(if AlertPeriod then TopArea else Double.NaN, if AlertPeriod then PutBBox else Double.NaN, Color.GRAY, Color.GRAY);
AddCloud(if AlertPeriod then BottomArea else Double.NaN, if AlertPeriod then CallTBox else Double.NaN, Color.GRAY, Color.GRAY);
Here is an example for one of the plots that you could use for all if this works for you:
Code:
plot TopArea = if showtodayOnly and !today then double.nan else HighestAll (if AlertPeriod then PutTopBox else Double.NaN) ;
 
Here is an example for one of the plots that you could use for all if this works for you:
Code:
plot TopArea = if showtodayOnly and !today then double.nan else HighestAll (if AlertPeriod then PutTopBox else Double.NaN) ;
Hey thank you so much!
 
Last edited:
Hey thanks but when I added that to both of the plots it did not draw anything on my chart. Any suggestions?
Here is the example expanded to the other plots. I had to add some values to your put, call and range to test the boxes with the code modifications.

Capture.jpg


input ShowTodayOnly={"No", default "Yes"};
input alertPeriodStart = 930;
input alertPeriodEnd = 1130;
def Today = if GetLastDay() == GetDay() then 1 else 0;
def StartAlertPeriod = SecondsTillTime(alertPeriodStart);
def EndAlertPeriod = SecondsTillTime(alertPeriodEnd);
def AlertPeriod = If (StartAlertPeriod <= 0 and EndAlertPeriod > 0, close, 0);

input PutLevelStart = 0.0;
input CallLevelStart = 0.0;
input Range = 0.0;

input HideBoxLines = Yes;
input HideLabels = Yes;

def PutTopBox = PutLevelStart + Range;
def CallBottomBox = CallLevelStart - Range;

plot TopArea = if showtodayOnly and !today then double.nan else HighestAll (if AlertPeriod then PutTopBox else Double.NaN) ;
TopArea.SetDefaultColor(Color.GRAY);
TopArea.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TopArea.SetHiding(HideBoxLines);

plot BottomArea = if showtodayOnly and !today then double.nan else HighestAll (if AlertPeriod then CallBottomBox else Double.NaN);
BottomArea.SetDefaultColor(Color.GRAY);
BottomArea.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
BottomArea.SetHiding(HideBoxLines);

plot PutBBox = if showtodayOnly and !today then double.nan else LowestAll (if AlertPeriod then PutLevelStart else Double.NaN);
PutBBox.SetDefaultColor(Color.GRAY);
PutBBox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PutBBox.SetHiding(HideBoxLines);

plot CallTBox = if showtodayOnly and !today then double.nan else HighestAll (if AlertPeriod then CallLevelStart else Double.NaN);
CallTBox.SetDefaultColor(Color.GRAY);
CallTBox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
CallTBox.SetHiding(HideBoxLines);

AddCloud(if AlertPeriod then TopArea else Double.NaN, if AlertPeriod then PutBBox else Double.NaN, Color.GRAY, Color.GRAY);
AddCloud(if AlertPeriod then BottomArea else Double.NaN, if AlertPeriod then CallTBox else Double.NaN, Color.GRAY, Color.GRAY);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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