NinjaScript > Language Reference > Drawing >

DrawRegion()

Print this Topic Previous pageReturn to chapter overviewNext page

Definition
Draws a region on a chart.

 

Method Return Value

An IRegion object that represents the draw object.

 

Syntax

DrawRegion(string tag, int startBarsAgo, int endBarsAgo, IDataSeries series, double y, Color outlineColor, Color areaColor, int areaOpacity)
DrawRegion(string tag, int startBarsAgo, int endBarsAgo, IDataSeries series1, IDataSeries series2, Color outlineColor, Color areaColor, int areaOpacity)

DrawRegion(string tag, DateTime startTime, DateTime endTime, IDataSeries series, double y, Color outlineColor, Color areaColor, int areaOpacity)

DrawRegion(string tag, DateTime startTime, DateTime endTime, IDataSeries series1, IDataSeries series2, Color outlineColor, Color areaColor, int areaOpacity)
 

Parameters

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.

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.

endBarsAgo

The end bar (x axis co-ordinate) where the draw object will terminate

endTime

The end time where the draw object will terminate

series, series1, series2

Any DataSeries type object such as an indicator, Close, High, Low etc.. The value of the object will represent a y value.

y

Any double value

outlineColor

Region outline color (reference)

areaColor

Region fill color (reference)

areaOpacity

Sets the level of transparency for the fill color. Valid values between 0 - 10. (0 = completely transparent, 10 = no opacity)

 

 

Examples

// Fills in the region between the upper and lower bollinger bands
DrawRegion("tag1", CurrentBar, 0, Bollinger(2, 14).Upper, Bollinger(2, 14).Lower, Color.Empty, Color.Lime, 2);

 

Tips
1. Pass in Color.Empty to the "outlineColor" parameter if you do not want to have an outline color.
2. If you wanted to fill a region between a value (20 period simple moving average) and the upper edge of the chart, pass in an extreme value to the "y" parameter such as 1000000.

3. Should you be drawing regions based on DataSeries objects instead of indicator plots, be sure to create the DataSeries with the MaximumBarsLookBack.Infinite parameter if the region you are drawing would be maintained on the chart for more than 256 bars back.