rotatedRectangle
The rotatedRectangle method lets you draw a rectangle that can be tilted instead of only being horizontal. It’s useful for marking angled zones, trend-aligned ranges, or tilted consolidation areas.
Syntax (one line)
rotatedRectangle(startTime, topPrice, endTime, bottomPrice, styles?, text?)
Parameters
startTime (number) · Time of the first corner (usually left side).
topPrice (number) · Price of the top side at the first corner.
endTime (number) · Time of the opposite corner (usually right side).
bottomPrice (number) · Price of the bottom side at the opposite corner.
styles (RotatedRectangleLineToolOverrides) · Options for customizing look:
backgroundColor(RGBAColor | BaseColors) · Fill color.color(RGBAColor | BaseColors) · Border color.fillBackground(boolean) · Fill on/off.linewidth(number) · Border thickness.transparency(number) · 0–100 fill transparency (higher = lighter).text(string) · Optional label text displayed on the shape.
Return Value
(string) · The drawing ID of the created rotated rectangle.
Example
What this does: Every 70 candles, it draws a rotated rectangle that highlights a tilted range zone.
//@version=1
init = () => {
indicator({ onMainPanel: true, format: 'inherit' });
};
onTick = () => {
if (index % 70 === 0) { // draw occasionally to keep chart clean
// 1) Style (RotatedRectangleLineToolOverrides)
const style = {
color: color.red,
linewidth: 2,
fillBackground: true,
backgroundColor: color.rgba(255, 0, 0, 0.2),
transparency: 80
};
// 2) Draw the rotated rectangle
rotatedRectangle(time(60), high(60), time(10), low(10), style, "Tilted Zone");
}
};Tips
Use rotated rectangles to capture sloping ranges that align with trend direction.
Keep transparency high so candles remain visible.
Warning
Avoid setting both
linewidthvery thick and low transparency together—it can hide too much price action.
Good Practice
Stick to consistent colors (e.g., red for bearish zones, green for bullish ones).
Label rotated rectangles with short names like “Bear Box” or “Trend Range” for clarity.
Last updated