Snap rectangles

vsquad22

New member
Hello,

I want to draw a rectangle (the blue one shown below), duplicate it and snap it above (green) and below (red) to create a stack of 5 or more rectangles of the exact same height so it looks something like this. The snapping to each other is important as it makes it easier to stack at exact price levels. Right now, I'm having to go into each individual rectangle drawing and type in the required price levels so it stacks exactly above or below the other as well as the time/date to ensure they start at the same time.

I'd also like the rectangles to have a white border showing the meeting point between them and the price at the top and bottom of each rectangle (shown on the right of the picture before the black column showing the price scale).

Also, if possible, I'd like the bid/ask lines to be shown. The indicators I've found here haven't been that good as they were just following the candle without specifically showing the bid/ask.

If it is relevant, this is for trading ES futures on the 1 minute timeframe.

Thank you.

1749547695638.png
 
Solution
Hello,

I want to draw a rectangle (the blue one shown below), duplicate it and snap it above (green) and below (red) to create a stack of 5 or more rectangles of the exact same height so it looks something like this. The snapping to each other is important as it makes it easier to stack at exact price levels. Right now, I'm having to go into each individual rectangle drawing and type in the required price levels so it stacks exactly above or below the other as well as the time/date to ensure they start at the same time.

I'd also like the rectangles to have a white border showing the meeting point between them and the price at the top and bottom of each rectangle (shown on the right of the picture before the black column showing...
Hello,

I want to draw a rectangle (the blue one shown below), duplicate it and snap it above (green) and below (red) to create a stack of 5 or more rectangles of the exact same height so it looks something like this. The snapping to each other is important as it makes it easier to stack at exact price levels. Right now, I'm having to go into each individual rectangle drawing and type in the required price levels so it stacks exactly above or below the other as well as the time/date to ensure they start at the same time.

I'd also like the rectangles to have a white border showing the meeting point between them and the price at the top and bottom of each rectangle (shown on the right of the picture before the black column showing the price scale).

Also, if possible, I'd like the bid/ask lines to be shown. The indicators I've found here haven't been that good as they were just following the candle without specifically showing the bid/ask.

If it is relevant, this is for trading ES futures on the 1 minute timeframe.

Thank you.

this draws 3 colored regions, a middle area, and an upper green region and a lower red region.
it draws white lines spaced evenly apart , defining 5 areas above and 5 areas below.

user enters,
.. the middle region lower price level ( default 6220 )
.. the spacing amount ( default 3.5 )

Code:
#shaded_regions_above_below
#https://usethinkscript.com/threads/snap-rectangles.21138/
#Snap rectangles

DefineGlobalColor("above", CreateColor(0, 255, 0));
DefineGlobalColor("mid", CreateColor(128, 128, 128));
DefineGlobalColor("below", CreateColor(255, 0, 0));
DefineGlobalColor("line", color.white);
# GlobalColor("above");

input shaded_height = 3.5;
input bottom_of_center_region = 6220.0;

plot mid0 = bottom_of_center_region;
plot mid1 = mid0 + shaded_height;
mid0.setdefaultcolor(GlobalColor("line"));
mid1.setdefaultcolor(GlobalColor("line"));

plot above1 = mid1 + (1 * shaded_height);
above1.setdefaultcolor(GlobalColor("line"));
plot above2 = mid1 + (2 * shaded_height);
above2.setdefaultcolor(GlobalColor("line"));
plot above3 = mid1 + (3 * shaded_height);
above3.setdefaultcolor(GlobalColor("line"));
plot above4 = mid1 + (4 * shaded_height);
above4.setdefaultcolor(GlobalColor("line"));
plot above5 = mid1 + (5 * shaded_height);
above5.setdefaultcolor(GlobalColor("line"));

plot below1 = mid0 - (1 * shaded_height);
below1.setdefaultcolor(GlobalColor("line"));
plot below2 = mid0 - (2 * shaded_height);
below2.setdefaultcolor(GlobalColor("line"));
plot below3 = mid0 - (3 * shaded_height);
below3.setdefaultcolor(GlobalColor("line"));
plot below4 = mid0 - (4 * shaded_height);
below4.setdefaultcolor(GlobalColor("line"));
plot below5 = mid0 - (5 * shaded_height);
below5.setdefaultcolor(GlobalColor("line"));

addcloud(above5, mid1, GlobalColor("above"));
addcloud(mid1, mid0, GlobalColor("mid"));
addcloud(mid0, below5, GlobalColor("below"));
#
 

Attachments

  • Capture.JPG
    Capture.JPG
    92.8 KB · Views: 25
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
247 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