2.2 The plots[] array

The plots[] array in the object you return from UDI.onInit() describes the different types of values which your UDI draws: a line, a histogram etc.

Your UDI can draw any number of different plots. For example, to draw something like the standard Bollinger Band indicator, you would use 4 plots: a channel (for the filled high-low range) plus 3 line plots for the centre line, the upper line, and the lower line.

Your plots[] can be empty if your indicator only adds drawings, or event markers etc, to the chart.

Each plot in the array must have a caption, and a type. The type of plot determines how many values you need to pass back from UDI.onCalculate(). If you are drawing a channel plus a line, then you will need to pass back 3 arrays of values in UDI.onCalculate(): 2 for the channel plus 1 for the line.

Plot type

Values

Description

line

1

Simple line

point

1

Individual points rather than a continuous line

histogram

1

Histogram; column starting at zero

histogramPositiveNegative

1

Histogram with different colours for >0 and <0

floatingHistogram

3

Floating histogram from A to B, rather than 0 to B, and/or a coloured histogram. Uses three output buffers. The first two are the A and B values for the histogram. The third buffer contains colours, which can be left as null to use the default colour specified for the plot.

channel

2

Filled channel (first series is the upper value; second series is the lower value)

candles

4

Candles (with open, high, low, close)

The full details of each plot are as follows. The only compulsory properties which you must provide are caption and type. All the other properties have defaults. Some members of the plot definition only apply to particular types of plot.

Property

Description

caption

The display name for the plot

type

The type of plot; one of the values listed above

noAlerts

Prevent users being able to set alerts on the value of this plot. (Not applicable to point plots; always true.)

color

HTML colour code for the plot, e.g. "red", "#FF0000", "rgba(255,0,0,0.5)". For histogramPositiveNegative or candles plots, this should be a comma-separated list of two colours, e.g. "red,#008000"

lineWidth

Only applicable to line or point plots. Width of the line/marker to draw.

lineStyle

Only applicable to line or point plots. Style for the marker/line: "solid", "dash", "dot". It can also be any character from the Font Awesome font, in the form "icon-aaaa" where "aaaa" is the hex code of the character, such as "f0ab".

markerOffset

Only applicable to point plots. Offset in pixels for displaying the marker. A negative value is above the price; a positive value is below the price. See the example fractal UDI for a typical use of the markerOffset, displaying markers above the high of a bar or below its low.

Last updated