> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# Draw.Rectangle()

## Definition

Draws a rectangle.

## Method Return Value

A **[Rectangle](/developer/desktop-sdk/references/common/drawing/draw-rectangle/rectangle)** object that represents the draw object.

## Syntax

`Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush)`

`Draw.Rectangle(NinjaScriptBase owner, string tag, DateTime startTime, double startY, DateTime endTime, double endY, Brush brush)`

`Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, Brush areaBrush, int areaOpacity)`

`Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime startTime, double startY, DateTime endTime, double endY, Brush brush, Brush areaBrush, int areaOpacity)`

`Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, bool drawOnPricePanel)`

`Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush, Brush areaBrush, int areaOpacity, bool drawOnPricePanel)`

`Draw.Rectangle(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime startTime, double startY, DateTime endTime, double endY, Brush brush, Brush areaBrush, int areaOpacity, bool drawOnPricePanel)`

`Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, bool isGlobal, string templateName)`

`Draw.Rectangle(NinjaScriptBase owner, string tag, DateTime startTime, double startY, DateTime endTime, double endY, bool isGlobal, string templateName)`

## Parameters

| Parameter        | Description                                                                                                                                                                                                                                               |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| owner            | The hosting **NinjaScript** object which is calling the draw method. Typically will be the object which is calling the draw method (e.g., "this").                                                                                                        |
| tag              | A user defined unique id used to reference the draw object. For example, if you pass in a value of "myTag", each time this tag is used, the same draw object is modified. If unique tags are used each time, a new draw object will be created each time. |
| isAutoScale      | Determines if the draw object will be included in the y-axis scale. Default value is false.                                                                                                                                                               |
| startBarsAgo     | The starting bar (x axis co-ordinate) where the draw object will be drawn. For example, a value of 10 would paint the draw object 10 bars back.                                                                                                           |
| startTime        | The starting time where the draw object will be drawn.                                                                                                                                                                                                    |
| startY           | The starting y value co-ordinate where the draw object will be drawn.                                                                                                                                                                                     |
| endBarsAgo       | The end bar (x axis co-ordinate) where the draw object will terminate.                                                                                                                                                                                    |
| endTime          | The end time where the draw object will terminate.                                                                                                                                                                                                        |
| endY             | The end y value co-ordinate where the draw object will terminate.                                                                                                                                                                                         |
| brush            | The brush used to color the outline of draw object ([reference](https://msdn.microsoft.com/en-us/library/system.windows.media.brushes%28v=vs.110%29.aspx)).                                                                                               |
| areaBrush        | The brush used to color the fill area of the draw object ([reference](https://msdn.microsoft.com/en-us/library/system.windows.media.brushes%28v=vs.110%29.aspx)).                                                                                         |
| areaOpacity      | Sets the level of transparency for the fill color. Valid values between 0 - 100. (0 = completely transparent, 100 = no opacity).                                                                                                                          |
| drawOnPricePanel | Determines if the draw-object should be on the price panel or a separate panel.                                                                                                                                                                           |
| isGlobal         | Determines if the draw object will be global across all charts which match the instrument.                                                                                                                                                                |
| templateName     | The name of the drawing tool template the object will use to determine various visual properties (empty string could be used to just use the UI default visuals instead).                                                                                 |

## Examples

```csharp
// Draws a blue rectangle from the low 10 bars back to the high of 5 bars back
Draw.Rectangle(this, "tag1", 10, Low[10] - TickSize, 5, High[5] + TickSize, Brushes.Blue);

// Draws a blue rectangle from the low 10 bars back to the high of 5 bars back with a fill color or pale green with a transparency level of 2
Draw.Rectangle(this, "tag1", false, 10, Low[10] - TickSize, 5, High[5] + TickSize, Brushes.PaleGreen, Brushes.PaleGreen, 2);
```