NinjaScript > Language Reference > Drawing >

DrawLine()

Print this Topic Previous pageReturn to chapter overviewNext page

Definition
Draws a line between two points.

 

Method Return Value

An ILine object that represents the draw object.

 

Syntax

DrawLine(string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color)
DrawLine(string tag, bool autoScale, int startBarsAgo, double startY, int endBarsAgo, double endY, Color color, DashStyle dashStyle, int width)

DrawLine(string tag, bool autoScale, DateTime startTime, double startY, DateTime endTime, double endY, Color color, DashStyle dashStyle, int width)
 

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.

autoScale

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

color

The draw object color (reference)

dashStyle

DashStyle.Dash
DashStyle.DashDot
DashStyle.DashDotDot
DashStyle.Dot
DashStyle.Solid
(reference)

 

Note: Drawing objects with y values very far off the visible canvas can lead to performance hits. Fancier DashStyles like DashDotDot will also require more resources than simple DashStyles like Solid.

width

The width of the draw object

 

 

Examples

// Draws a dotted lime green line from 10 bars back to the current bar
// with a width of 2 pixels
DrawLine("tag1", false, 10, 1000, 0, 1001, Color.LimeGreen, DashStyle.Dot, 2);