Drawing

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Common >

Drawing

Previous page Return to chapter overview Next page

You can use NinjaScript to draw custom shapes, lines, text and colors on price and indicator panels from both Indicators and Strategies.

 

Draw Methods and Associated Return Types

Draw Method

Return Type

Draw.AndrewsPitchfork()

AndrewsPitchfork

Draw.Arc()

Arc

Draw.ArrowDown()

ArrowDown

Draw.ArrowLine()

ArrowLine

Draw.ArrowUp()

ArrowUp

Draw.Diamond()

Diamond

Draw.Dot()

Dot

Draw.Ellipse()

Ellipse

Draw.ExtendedLine()

ExtendedLine

Draw.FibonacciCircle()

FibonacciCircle

Draw.FibonacciExtensions()

FibonacciExtensions

Draw.FibonacciRetracements()

FibonacciRetracements

Draw.FibonacciTimeExtensions()

FibonacciTimeExtensions

Draw.GannFan()

GannFan

Draw.HorizontalLine()

HorizontalLine

Draw.Line()

Line

Draw.Ray()

Ray

Draw.Rectangle()

Rectangle

Draw.Region()

Region

Draw.RegionHighlightX()

RegionHighlightX

Draw.RegionHighlightY()

RegionHighlightY

Draw.RegressionChannel()

RegressionChannel

Draw.RiskReward()

RiskReward

Draw.Ruler()

Ruler

Draw.Square()

Square

Draw.Text()

Text

Draw.TextFixed()

TextFixed

Draw.TrendChannel()

TrendChannel

Draw.Triangle()

Triangle

Draw.TriangleDown()

TriangleDown

Draw.TriangleUp()

TriangleUp

Draw.VerticalLine()

VerticalLine

 

 

Drawing Methods and Properties

Property

Description

AllowRemovalOfDrawObjects

Determines if programmatically drawn DrawObjects can be manually removed from the chart

BackBrush

Sets the brush used for painting the chart panel's background color for the current bar

BackBrushAll

Sets the brush used for painting the chart's background color for the current bar

BackBrushes

A collection of historical brushes used for the background colors for the chart panel

BackBrushesAll

A collection of historical brushes used for the background colors for all chart panels

BarBrush

Sets the brush used for painting the color of a price bar's body

BarBrushes

A collection of historical brushes used for painting the color of a price bar's body

Brushes

A collection of static, predefined Brushes supplied by the .NET Framework

CandleOutlineBrush

Sets the outline Brush of a candlestick

CandleOutlineBrushes

A collection of historical outline brushes for candlesticks

DrawObjects

A collection holding all of the drawn chart objects for the primary bar series

IDrawingTool

Represents an interface that exposes information regarding a drawn chart object

RemoveDrawObject()

Removes a draw object from the chart based on its tag value

RemoveDrawObjects()

Removes all draw objects originating from the indicator or strategy from the chart

SimpleFont Class

Defines a particular font configuration

 

1.Custom graphics for custom indicators can be painted on either the price panel or indicator panel. You could for example have a custom indicator displayed in an indicator panel yet have associated custom graphics painted on the price panel. The "DrawOnPricePanel" property is set to true by default, which means that custom graphics will always be painted on the price panel, even if the indicator is plotted in a separate panel. If you want your custom graphics to be plotted on the indicator panel, set this property to false in the OnStateChange() method of your custom indicator.
2.Set unique tag values for each draw object, unless you intend for new draw objects to replace existing objects with the same tag. A common trick is to incorporate the bar number as part of the unique tag identifier. For example, if you wanted to draw a dot that indicated a buying condition above a bar, you could express it:

 

Draw.Dot(this, CurrentBar.ToString() + "Buy", false, 0, High[0] + TickSize, Brushes.ForestGreen);

 

3. Draw methods will not work if they are called from the OnStateChange() method.