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: 75
Solution
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"));
#
Thank you very much! It took so long for the question to be posted as I am a free user that I managed to use a variety of chat/ai bots to create a couple that are similar to yours without any coding expertise and with a lot of headaches. They do exactly what I want but they have lots of lines of code (thinkscript warning: complex script, you may experience greater load times) which I have tried reduce without any success. I've pasted them below. If you wouldn't mind, can you see a way to reduce the number of lines of code, please? No worries, if not. Thank you!


Code:
input baseHigh = 5974.25;

input baseLow = 5970.25;

input boxStartTime = 1900;

input boxDurationHours = 16;

input heightPerBox = 5.25;

input runFromDate = 20250101;

input runToDate = 20250101;



def allowedDate = GetYYYYMMDD() >= runFromDate and GetYYYYMMDD() <= runToDate;

def isStart = SecondsFromTime(boxStartTime) == 0;

def barsToShow = Floor(boxDurationHours * 60 / (GetAggregationPeriod() / 60000));

def startBar = if isStart then BarNumber() else startBar[1];

def within = BarNumber() >= startBar and BarNumber() <= (startBar + barsToShow) and allowedDate;



# Base Zone (Blue)

plot baseTop = if within then baseHigh else Double.NaN;

plot baseBottom = if within then baseLow else Double.NaN;

AddCloud(baseTop, baseBottom, CreateColor(0, 0, 255), CreateColor(0, 0, 255));



#--------------------------------------------------------------------

# Upper Zones

# There are 14 upper zones. Their boundaries use:

# u0 = baseHigh, u1 = baseHigh + heightPerBox, ... , u14 = baseHigh + 14*heightPerBox

def u0 = baseHigh;

def u1 = baseHigh + 1 * heightPerBox;

def u2 = baseHigh + 2 * heightPerBox;

def u3 = baseHigh + 3 * heightPerBox;

def u4 = baseHigh + 4 * heightPerBox;

def u5 = baseHigh + 5 * heightPerBox;

def u6 = baseHigh + 6 * heightPerBox;

def u7 = baseHigh + 7 * heightPerBox;

def u8 = baseHigh + 8 * heightPerBox;

def u9 = baseHigh + 9 * heightPerBox;

def u10 = baseHigh + 10 * heightPerBox;

def u11 = baseHigh + 11 * heightPerBox;

def u12 = baseHigh + 12 * heightPerBox;

def u13 = baseHigh + 13 * heightPerBox;

def u14 = baseHigh + 14 * heightPerBox;



# Each zone is drawn with its own color:

# Zones 0–1: green; zones 2–5: purple; zones 6–13: teal.

AddCloud(if within then u1 else Double.NaN, if within then u0 else Double.NaN, CreateColor(0,255,0), CreateColor(0,255,0)); # Zone 0 (green)

AddCloud(if within then u2 else Double.NaN, if within then u1 else Double.NaN, CreateColor(0,255,0), CreateColor(0,255,0)); # Zone 1 (green)

AddCloud(if within then u3 else Double.NaN, if within then u2 else Double.NaN, CreateColor(238,130,238), CreateColor(238,130,238)); # Zone 2 (purple)

AddCloud(if within then u4 else Double.NaN, if within then u3 else Double.NaN, CreateColor(238,130,238), CreateColor(238,130,238)); # Zone 3 (purple)

AddCloud(if within then u5 else Double.NaN, if within then u4 else Double.NaN, CreateColor(238,130,238), CreateColor(238,130,238)); # Zone 4 (purple)

AddCloud(if within then u6 else Double.NaN, if within then u5 else Double.NaN, CreateColor(238,130,238), CreateColor(238,130,238)); # Zone 5 (purple)

AddCloud(if within then u7 else Double.NaN, if within then u6 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 6 (teal)

AddCloud(if within then u8 else Double.NaN, if within then u7 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 7 (teal)

AddCloud(if within then u9 else Double.NaN, if within then u8 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 8 (teal)

AddCloud(if within then u10 else Double.NaN, if within then u9 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 9 (teal)

AddCloud(if within then u11 else Double.NaN, if within then u10 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 10 (teal)

AddCloud(if within then u12 else Double.NaN, if within then u11 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 11 (teal)

AddCloud(if within then u13 else Double.NaN, if within then u12 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 12 (teal)

AddCloud(if within then u14 else Double.NaN, if within then u13 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 13 (teal)



# Plot white border lines at every boundary from u0 to u14:

plot w0 = if within then u0 else Double.NaN;

plot w1 = if within then u1 else Double.NaN;

plot w2 = if within then u2 else Double.NaN;

plot w3 = if within then u3 else Double.NaN;

plot w4 = if within then u4 else Double.NaN;

plot w5 = if within then u5 else Double.NaN;

plot w6 = if within then u6 else Double.NaN;

plot w7 = if within then u7 else Double.NaN;

plot w8 = if within then u8 else Double.NaN;

plot w9 = if within then u9 else Double.NaN;

plot w10 = if within then u10 else Double.NaN;

plot w11 = if within then u11 else Double.NaN;

plot w12 = if within then u12 else Double.NaN;

plot w13 = if within then u13 else Double.NaN;

plot w14 = if within then u14 else Double.NaN;



w0.SetPaintingStrategy(PaintingStrategy.LINE);

w1.SetPaintingStrategy(PaintingStrategy.LINE);

w2.SetPaintingStrategy(PaintingStrategy.LINE);

w3.SetPaintingStrategy(PaintingStrategy.LINE);

w4.SetPaintingStrategy(PaintingStrategy.LINE);

w5.SetPaintingStrategy(PaintingStrategy.LINE);

w6.SetPaintingStrategy(PaintingStrategy.LINE);

w7.SetPaintingStrategy(PaintingStrategy.LINE);

w8.SetPaintingStrategy(PaintingStrategy.LINE);

w9.SetPaintingStrategy(PaintingStrategy.LINE);

w10.SetPaintingStrategy(PaintingStrategy.LINE);

w11.SetPaintingStrategy(PaintingStrategy.LINE);

w12.SetPaintingStrategy(PaintingStrategy.LINE);

w13.SetPaintingStrategy(PaintingStrategy.LINE);

w14.SetPaintingStrategy(PaintingStrategy.LINE);



w0.SetDefaultColor(CreateColor(255,255,255));

w1.SetDefaultColor(CreateColor(255,255,255));

w2.SetDefaultColor(CreateColor(255,255,255));

w3.SetDefaultColor(CreateColor(255,255,255));

w4.SetDefaultColor(CreateColor(255,255,255));

w5.SetDefaultColor(CreateColor(255,255,255));

w6.SetDefaultColor(CreateColor(255,255,255));

w7.SetDefaultColor(CreateColor(255,255,255));

w8.SetDefaultColor(CreateColor(255,255,255));

w9.SetDefaultColor(CreateColor(255,255,255));

w10.SetDefaultColor(CreateColor(255,255,255));

w11.SetDefaultColor(CreateColor(255,255,255));

w12.SetDefaultColor(CreateColor(255,255,255));

w13.SetDefaultColor(CreateColor(255,255,255));

w14.SetDefaultColor(CreateColor(255,255,255));



w0.SetLineWeight(1);

w1.SetLineWeight(1);

w2.SetLineWeight(1);

w3.SetLineWeight(1);

w4.SetLineWeight(1);

w5.SetLineWeight(1);

w6.SetLineWeight(1);

w7.SetLineWeight(1);

w8.SetLineWeight(1);

w9.SetLineWeight(1);

w10.SetLineWeight(1);

w11.SetLineWeight(1);

w12.SetLineWeight(1);

w13.SetLineWeight(1);

w14.SetLineWeight(1);



#--------------------------------------------------------------------

# Lower Zones

# Define lower boundaries:

def d0 = baseLow;

def d1 = baseLow - 1 * heightPerBox;

def d2 = baseLow - 2 * heightPerBox;

def d3 = baseLow - 3 * heightPerBox;

def d4 = baseLow - 4 * heightPerBox;

def d5 = baseLow - 5 * heightPerBox;

def d6 = baseLow - 6 * heightPerBox;

def d7 = baseLow - 7 * heightPerBox;

def d8 = baseLow - 8 * heightPerBox;

def d9 = baseLow - 9 * heightPerBox;

def d10 = baseLow - 10 * heightPerBox;

def d11 = baseLow - 11 * heightPerBox;

def d12 = baseLow - 12 * heightPerBox;

def d13 = baseLow - 13 * heightPerBox;

def d14 = baseLow - 14 * heightPerBox;



# Color rules for lower zones:

# Zones 0–1: red; zones 2–5: grey; zones 6–13: teal.

AddCloud(if within then d0 else Double.NaN, if within then d1 else Double.NaN, CreateColor(255,0,0), CreateColor(255,0,0)); # Zone 0 (red)

AddCloud(if within then d1 else Double.NaN, if within then d2 else Double.NaN, CreateColor(255,0,0), CreateColor(255,0,0)); # Zone 1 (red)

AddCloud(if within then d2 else Double.NaN, if within then d3 else Double.NaN, CreateColor(211,211,211), CreateColor(211,211,211)); # Zone 2 (grey)

AddCloud(if within then d3 else Double.NaN, if within then d4 else Double.NaN, CreateColor(211,211,211), CreateColor(211,211,211)); # Zone 3 (grey)

AddCloud(if within then d4 else Double.NaN, if within then d5 else Double.NaN, CreateColor(211,211,211), CreateColor(211,211,211)); # Zone 4 (grey)

AddCloud(if within then d5 else Double.NaN, if within then d6 else Double.NaN, CreateColor(211,211,211), CreateColor(211,211,211)); # Zone 5 (grey)

AddCloud(if within then d6 else Double.NaN, if within then d7 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 6 (teal)

AddCloud(if within then d7 else Double.NaN, if within then d8 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 7 (teal)

AddCloud(if within then d8 else Double.NaN, if within then d9 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 8 (teal)

AddCloud(if within then d9 else Double.NaN, if within then d10 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 9 (teal)

AddCloud(if within then d10 else Double.NaN, if within then d11 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 10 (teal)

AddCloud(if within then d11 else Double.NaN, if within then d12 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 11 (teal)

AddCloud(if within then d12 else Double.NaN, if within then d13 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 12 (teal)

AddCloud(if within then d13 else Double.NaN, if within then d14 else Double.NaN, CreateColor(0,102,102), CreateColor(0,102,102)); # Zone 13 (teal)



# Lower borders: white lines at each boundary.

plot ld0 = if within then d0 else Double.NaN;

plot ld1 = if within then d1 else Double.NaN;

plot ld2 = if within then d2 else Double.NaN;

plot ld3 = if within then d3 else Double.NaN;

plot ld4 = if within then d4 else Double.NaN;

plot ld5 = if within then d5 else Double.NaN;

plot ld6 = if within then d6 else Double.NaN;

plot ld7 = if within then d7 else Double.NaN;

plot ld8 = if within then d8 else Double.NaN;

plot ld9 = if within then d9 else Double.NaN;

plot ld10 = if within then d10 else Double.NaN;

plot ld11 = if within then d11 else Double.NaN;

plot ld12 = if within then d12 else Double.NaN;

plot ld13 = if within then d13 else Double.NaN;

plot ld14 = if within then d14 else Double.NaN;



ld0.SetPaintingStrategy(PaintingStrategy.LINE);

ld1.SetPaintingStrategy(PaintingStrategy.LINE);

ld2.SetPaintingStrategy(PaintingStrategy.LINE);

ld3.SetPaintingStrategy(PaintingStrategy.LINE);

ld4.SetPaintingStrategy(PaintingStrategy.LINE);

ld5.SetPaintingStrategy(PaintingStrategy.LINE);

ld6.SetPaintingStrategy(PaintingStrategy.LINE);

ld7.SetPaintingStrategy(PaintingStrategy.LINE);

ld8.SetPaintingStrategy(PaintingStrategy.LINE);

ld9.SetPaintingStrategy(PaintingStrategy.LINE);

ld10.SetPaintingStrategy(PaintingStrategy.LINE);

ld11.SetPaintingStrategy(PaintingStrategy.LINE);

ld12.SetPaintingStrategy(PaintingStrategy.LINE);

ld13.SetPaintingStrategy(PaintingStrategy.LINE);

ld14.SetPaintingStrategy(PaintingStrategy.LINE);



ld0.SetDefaultColor(CreateColor(255,255,255));

ld1.SetDefaultColor(CreateColor(255,255,255));

ld2.SetDefaultColor(CreateColor(255,255,255));

ld3.SetDefaultColor(CreateColor(255,255,255));

ld4.SetDefaultColor(CreateColor(255,255,255));

ld5.SetDefaultColor(CreateColor(255,255,255));

ld6.SetDefaultColor(CreateColor(255,255,255));

ld7.SetDefaultColor(CreateColor(255,255,255));

ld8.SetDefaultColor(CreateColor(255,255,255));

ld9.SetDefaultColor(CreateColor(255,255,255));

ld10.SetDefaultColor(CreateColor(255,255,255));

ld11.SetDefaultColor(CreateColor(255,255,255));

ld12.SetDefaultColor(CreateColor(255,255,255));

ld13.SetDefaultColor(CreateColor(255,255,255));

ld14.SetDefaultColor(CreateColor(255,255,255));



ld0.SetLineWeight(1);

ld1.SetLineWeight(1);

ld2.SetLineWeight(1);

ld3.SetLineWeight(1);

ld4.SetLineWeight(1);

ld5.SetLineWeight(1);

ld6.SetLineWeight(1);

ld7.SetLineWeight(1);

ld8.SetLineWeight(1);

ld9.SetLineWeight(1);

ld10.SetLineWeight(1);

ld11.SetLineWeight(1);

ld12.SetLineWeight(1);

ld13.SetLineWeight(1);

ld14.SetLineWeight(1);

This one works fine too:

input baseHigh = 5974.25;

input baseLow = 5970.25;

input boxStartTime = 1900;

input boxDurationHours = 16;

input heightPerBox = 5.25;

input runFromDate = 20250101;

input runToDate = 20250101;



def allowedDate = GetYYYYMMDD() >= runFromDate and GetYYYYMMDD() <= runToDate;

def isStart = SecondsFromTime(boxStartTime) == 0;

def barsToShow = Floor(boxDurationHours * 60 / (GetAggregationPeriod() / 60000));

def startBar = if isStart then BarNumber() else startBar[1];

def within = BarNumber() >= startBar and BarNumber() <= (startBar + barsToShow) and allowedDate;



# Base Rectangle (Blue)

plot baseTop = if within then baseHigh else Double.NaN;

plot baseBottom = if within then baseLow else Double.NaN;

AddCloud(baseTop, baseBottom, CreateColor(0, 0, 255), CreateColor(0, 0, 255));



#######################

# Rectangles Above Base

#######################



AddCloud(if within then baseHigh + heightPerBox * 1 else Double.NaN,

if within then baseHigh else Double.NaN,

CreateColor(0, 255, 0), CreateColor(0, 255, 0));

plot topEdge1 = if within then baseHigh else Double.NaN;

topEdge1.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge1.SetDefaultColor(CreateColor(255, 255, 255));

topEdge1.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 2 else Double.NaN,

if within then baseHigh + heightPerBox * 1 else Double.NaN,

CreateColor(0, 255, 0), CreateColor(0, 255, 0));

plot topEdge2 = if within then baseHigh + heightPerBox * 1 else Double.NaN;

topEdge2.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge2.SetDefaultColor(CreateColor(255, 255, 255));

topEdge2.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 3 else Double.NaN,

if within then baseHigh + heightPerBox * 2 else Double.NaN,

CreateColor(238, 130, 238), CreateColor(238, 130, 238));

plot topEdge3 = if within then baseHigh + heightPerBox * 2 else Double.NaN;

topEdge3.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge3.SetDefaultColor(CreateColor(255, 255, 255));

topEdge3.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 4 else Double.NaN,

if within then baseHigh + heightPerBox * 3 else Double.NaN,

CreateColor(238, 130, 238), CreateColor(238, 130, 238));

plot topEdge4 = if within then baseHigh + heightPerBox * 3 else Double.NaN;

topEdge4.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge4.SetDefaultColor(CreateColor(255, 255, 255));

topEdge4.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 5 else Double.NaN,

if within then baseHigh + heightPerBox * 4 else Double.NaN,

CreateColor(238, 130, 238), CreateColor(238, 130, 238));

plot topEdge5 = if within then baseHigh + heightPerBox * 4 else Double.NaN;

topEdge5.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge5.SetDefaultColor(CreateColor(255, 255, 255));

topEdge5.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 6 else Double.NaN,

if within then baseHigh + heightPerBox * 5 else Double.NaN,

CreateColor(238, 130, 238), CreateColor(238, 130, 238));

plot topEdge6 = if within then baseHigh + heightPerBox * 5 else Double.NaN;

topEdge6.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge6.SetDefaultColor(CreateColor(255, 255, 255));

topEdge6.SetLineWeight(1);



#############################

# Additional Rectangles Above Base (Teal)

#############################



AddCloud(if within then baseHigh + heightPerBox * 7 else Double.NaN,

if within then baseHigh + heightPerBox * 6 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot topEdge7 = if within then baseHigh + heightPerBox * 6 else Double.NaN;

topEdge7.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge7.SetDefaultColor(CreateColor(255, 255, 255));

topEdge7.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 8 else Double.NaN,

if within then baseHigh + heightPerBox * 7 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot topEdge8 = if within then baseHigh + heightPerBox * 7 else Double.NaN;

topEdge8.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge8.SetDefaultColor(CreateColor(255, 255, 255));

topEdge8.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 9 else Double.NaN,

if within then baseHigh + heightPerBox * 8 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot topEdge9 = if within then baseHigh + heightPerBox * 8 else Double.NaN;

topEdge9.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge9.SetDefaultColor(CreateColor(255, 255, 255));

topEdge9.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 10 else Double.NaN,

if within then baseHigh + heightPerBox * 9 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot topEdge10 = if within then baseHigh + heightPerBox * 9 else Double.NaN;

topEdge10.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge10.SetDefaultColor(CreateColor(255, 255, 255));

topEdge10.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 11 else Double.NaN,

if within then baseHigh + heightPerBox * 10 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot topEdge11 = if within then baseHigh + heightPerBox * 10 else Double.NaN;

topEdge11.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge11.SetDefaultColor(CreateColor(255, 255, 255));

topEdge11.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 12 else Double.NaN,

if within then baseHigh + heightPerBox * 11 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot topEdge12 = if within then baseHigh + heightPerBox * 11 else Double.NaN;

topEdge12.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge12.SetDefaultColor(CreateColor(255, 255, 255));

topEdge12.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 13 else Double.NaN,

if within then baseHigh + heightPerBox * 12 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot topEdge13 = if within then baseHigh + heightPerBox * 12 else Double.NaN;

topEdge13.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge13.SetDefaultColor(CreateColor(255, 255, 255));

topEdge13.SetLineWeight(1);



AddCloud(if within then baseHigh + heightPerBox * 14 else Double.NaN,

if within then baseHigh + heightPerBox * 13 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot topEdge14 = if within then baseHigh + heightPerBox * 13 else Double.NaN;

topEdge14.SetPaintingStrategy(PaintingStrategy.LINE);

topEdge14.SetDefaultColor(CreateColor(255, 255, 255));

topEdge14.SetLineWeight(1);



########################

# Rectangles Below Base

########################



AddCloud(if within then baseLow else Double.NaN,

if within then baseLow - heightPerBox * 1 else Double.NaN,

CreateColor(255, 0, 0), CreateColor(255, 0, 0));

plot botEdge1 = if within then baseLow else Double.NaN;

botEdge1.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge1.SetDefaultColor(CreateColor(255, 255, 255));

botEdge1.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 1 else Double.NaN,

if within then baseLow - heightPerBox * 2 else Double.NaN,

CreateColor(255, 0, 0), CreateColor(255, 0, 0));

plot botEdge2 = if within then baseLow - heightPerBox * 1 else Double.NaN;

botEdge2.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge2.SetDefaultColor(CreateColor(255, 255, 255));

botEdge2.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 2 else Double.NaN,

if within then baseLow - heightPerBox * 3 else Double.NaN,

CreateColor(211, 211, 211), CreateColor(211, 211, 211));

plot botEdge3 = if within then baseLow - heightPerBox * 2 else Double.NaN;

botEdge3.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge3.SetDefaultColor(CreateColor(255, 255, 255));

botEdge3.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 3 else Double.NaN,

if within then baseLow - heightPerBox * 4 else Double.NaN,

CreateColor(211, 211, 211), CreateColor(211, 211, 211));

plot botEdge4 = if within then baseLow - heightPerBox * 3 else Double.NaN;

botEdge4.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge4.SetDefaultColor(CreateColor(255, 255, 255));

botEdge4.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 4 else Double.NaN,

if within then baseLow - heightPerBox * 5 else Double.NaN,

CreateColor(211, 211, 211), CreateColor(211, 211, 211));

plot botEdge5 = if within then baseLow - heightPerBox * 4 else Double.NaN;

botEdge5.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge5.SetDefaultColor(CreateColor(255, 255, 255));

botEdge5.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 5 else Double.NaN,

if within then baseLow - heightPerBox * 6 else Double.NaN,

CreateColor(211, 211, 211), CreateColor(211, 211, 211));

plot botEdge6 = if within then baseLow - heightPerBox * 5 else Double.NaN;

botEdge6.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge6.SetDefaultColor(CreateColor(255, 255, 255));

botEdge6.SetLineWeight(1);



# Added white border for the bottom edge of the lowest grey rectangle

plot bottomBorderGrey = if within then baseLow - heightPerBox * 6 else Double.NaN;

bottomBorderGrey.SetPaintingStrategy(PaintingStrategy.LINE);

bottomBorderGrey.SetDefaultColor(CreateColor(255, 255, 255));

bottomBorderGrey.SetLineWeight(1);



#############################

# Additional Rectangles Below Base (Teal)

#############################



AddCloud(if within then baseLow - heightPerBox * 6 else Double.NaN,

if within then baseLow - heightPerBox * 7 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot botEdge7 = if within then baseLow - heightPerBox * 7 else Double.NaN;

botEdge7.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge7.SetDefaultColor(CreateColor(255, 255, 255));

botEdge7.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 7 else Double.NaN,

if within then baseLow - heightPerBox * 8 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot botEdge8 = if within then baseLow - heightPerBox * 8 else Double.NaN;

botEdge8.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge8.SetDefaultColor(CreateColor(255, 255, 255));

botEdge8.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 8 else Double.NaN,

if within then baseLow - heightPerBox * 9 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot botEdge9 = if within then baseLow - heightPerBox * 9 else Double.NaN;

botEdge9.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge9.SetDefaultColor(CreateColor(255, 255, 255));

botEdge9.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 9 else Double.NaN,

if within then baseLow - heightPerBox * 10 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot botEdge10 = if within then baseLow - heightPerBox * 10 else Double.NaN;

botEdge10.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge10.SetDefaultColor(CreateColor(255, 255, 255));

botEdge10.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 10 else Double.NaN,

if within then baseLow - heightPerBox * 11 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot botEdge11 = if within then baseLow - heightPerBox * 11 else Double.NaN;

botEdge11.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge11.SetDefaultColor(CreateColor(255, 255, 255));

botEdge11.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 11 else Double.NaN,

if within then baseLow - heightPerBox * 12 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot botEdge12 = if within then baseLow - heightPerBox * 12 else Double.NaN;

botEdge12.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge12.SetDefaultColor(CreateColor(255, 255, 255));

botEdge12.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 12 else Double.NaN,

if within then baseLow - heightPerBox * 13 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot botEdge13 = if within then baseLow - heightPerBox * 13 else Double.NaN;

botEdge13.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge13.SetDefaultColor(CreateColor(255, 255, 255));

botEdge13.SetLineWeight(1);



AddCloud(if within then baseLow - heightPerBox * 13 else Double.NaN,

if within then baseLow - heightPerBox * 14 else Double.NaN,

CreateColor(0, 102, 102), CreateColor(0, 102, 102));

plot botEdge14 = if within then baseLow - heightPerBox * 14 else Double.NaN;

botEdge14.SetPaintingStrategy(PaintingStrategy.LINE);

botEdge14.SetDefaultColor(CreateColor(255, 255, 255));

botEdge14.SetLineWeight(1);
 
Last edited by a moderator:

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