I'd like to have each side of the box have different colours. Here's my code:
//@version=4
study("My Script", overlay=true)
// box.new(left, top, right, bottom, border_color, border_width, border_style, extend, xloc, bgcolor)
b = box.new(bar_index[100], highest(high,50), bar_index[10], lowest(low, 50), color.purple, 1, line.style_solid, extend.none, xloc.bar_index, color.new(color.purple, 90))
box.delete(b[1])
Not possible with a single box object.
However you can build your box with 4 lines with different colors, as is shown in the example below with a custom f_rect function:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © e2e4mfck
//@version=4
study("Colorized box", overlay = false)
f_rect(_x1, _y1, _x2, _y2, _color1, _color2, _color3, _color4 ) =>
line.new(_x1, _y1, _x1, _y2, xloc.bar_index, extend.none, _color1, line.style_solid)
line.new(_x2, _y1, _x2, _y2, xloc.bar_index, extend.none, _color2, line.style_solid)
line.new(_x1, _y2, _x2, _y2, xloc.bar_index, extend.none, _color3, line.style_solid)
line.new(_x1, _y1, _x2, _y1, xloc.bar_index, extend.none, _color4, line.style_solid)
if barstate.islastconfirmedhistory
f_rect(bar_index, 0, bar_index[10], 10, color.red, color.green, color.purple, color.blue)