Drawing scripts are used for drawing a visual object on a chart or as part of another script's implementation (such as a Trading Strategy script). Drawing scripts can significantly slow down the backtesting process when used from another script, so please use with caution.


Setup


A Drawing script can be drawn manually on a chart just like in any other technical analysis software, or it can be plotted on a chart from a Trading Strategy script.


Functions


Name

Description

OnInitialize()

This function is called when a new drawing instance is created.

OnChartSetup()

This function is used for setting up the drawing on the chart and registering its pens (see the DrawingRegisterPen function).

OnDraw()

This function is used to draw the drawing by setting all of its anchor points, lines and labels on a virtual canvas.

The canvas x-axis values are the date and time of the underlying symbol bars and its y-axis values are the symbol prices.


The location of the drawing on the canvas is specified by the drawing anchor points, which can either be specified by clicking on a chart or from another script.


Function Details


OnInitialize()

This function is called when a new drawing instance is created.


Parameters


Type

Identifier

Description

int

symbolIndex

The underlying symbol index for the drawing.


OnChartSetup()

This function is used for setting up the drawing on the chart and registering its pens (see the DrawingRegisterPen function).


OnDraw()

This function is used to draw the drawing by setting all of its anchor points, lines and labels on a virtual canvas.

The canvas x-axis values are the date and time of the underlying symbol bars and its y-axis values are the symbol prices.


The location of the drawing on the canvas is specified by the drawing anchor points, which can either be specified by clicking on a chart or from another script.