//@version=6 indicator("Order Levels Visualization", overlay=true) // Create a new box for each new candle //box := box.new(bar_index, high, bar_index + 10, low, color.gray, 1, line.style_dashed, extend.none, xloc.bar_index) // Input parameters for order levels buyLimitPrice = input.price(title="Buy Limit Price", defval=0.0) sellLimitPrice = input.price(title="Sell Limit Price", defval=0.0) // Input parameters for rectangle width and shading rectangleWidth = input.int(title="Rectangle Width (Price Units)", defval=10, minval=1) showDebugInfo = input.bool(title="Show Debug Information", defval=false) buyShadeColor = input.color(title="Buy Limit Shade Color", defval=color.new(color.green, 90)) sellShadeColor = input.color(title="Sell Limit Shade Color", defval=color.new(color.red, 90)) borderColor = input.color(title="Border Color", defval=color.gray) // Function to draw rectangles and shaded areas drawOrderLevels() => // Clear any existing boxes var boxes = array.new_box() // Buy limit rectangle if buyLimitPrice > 0 buyRectTop = buyLimitPrice + rectangleWidth / 2 buyRectBottom = buyLimitPrice - rectangleWidth / 2 box buyBox = box.new(left=bar_index, top=buyRectTop, right=bar_index + 500, bottom=buyRectBottom, border_color=borderColor, border_width=1, bgcolor=buyShadeColor) // Debug information if showDebugInfo label buyLabel = label.new(x=bar_index, y=buyLimitPrice, text='Buy Limit\n' + 'Price: ' + str.tostring(buyLimitPrice, format.mintick) + '\n' + 'Top: ' + str.tostring(buyRectTop, format.mintick) + '\n' + 'Bottom: ' + str.tostring(buyRectBottom, format.mintick), color=color.blue, style=label.style_note) array.push(boxes, buyBox) // Sell limit rectangle if sellLimitPrice > 0 sellRectTop = sellLimitPrice + rectangleWidth / 2 sellRectBottom = sellLimitPrice - rectangleWidth / 2 box sellBox = box.new(left=bar_index, top=sellRectTop, right=bar_index + 500, bottom=sellRectBottom, border_color=borderColor, border_width=1, bgcolor=sellShadeColor) // Debug information if showDebugInfo label sellLabel = label.new(x=bar_index, y=sellLimitPrice, text='Sell Limit\n' + 'Price: ' + str.tostring(sellLimitPrice, format.mintick) + '\n' + 'Top: ' + str.tostring(sellRectTop, format.mintick) + '\n' + 'Bottom: ' + str.tostring(sellRectBottom, format.mintick), color=color.red, style=label.style_note) array.push(boxes, sellBox) // Plot the order levels drawOrderLevels()