Class: StudyDescriptor

CIQ.Studies. StudyDescriptor


new StudyDescriptor(name, type, panel, inputs, outputs, parameters)

Creates a study descriptor which contains all of the information necessary to handle a study. Also provides convenience methods to extract information from it.

Do not call directly or try to manually create your own study descriptor, but rather always use the one returned by CIQ.Studies.addStudy

Parameters:
Name Type Description
name string

The name of the study. This should be unique to the chart. For instance if there are two RSI panels then they should be of different periods and named accordingly. Usually this is determined automatically by the library.

type string

The type of study, which can be used as a look up in the StudyLibrary

panel string

The name of the panel that contains the study

inputs object

Names and values of input fields

outputs object

Names and values (colors) of outputs

parameters object

Additional parameters that are unique to the particular study

Members


inputs

Properties:
Name Type Description
inputs object

Keys for each possible study input with descriptors for the set and default values.


max

Properties:
Name Type Description
max number

The maximum data point.


min

Properties:
Name Type Description
min number

The minimum data point.


name

Properties:
Name Type Description
name string

The study's ID. Includes ZWNJ characters. Please note: To facilitate study name translations, study names use zero-width non-joiner (unprintable) characters to delimit the general study name from the specific study parameters. Example: "\u200c"+"Aroon"+"\u200c"+" (14)". At translation time, the library will split the text into pieces using the ZWNJ characters, parentheses and commas to just translate the required part of a study name. For more information on ZWNJ characters see: Zero-width_non-joiner. Please be aware of these ZWNJ characters, which will now be present in all study names and corresponding panel names; including the layout.studies study keys. Affected fields in the study descriptors could be id , display, name and panel.
To prevent issues, always use the names returned in the study descriptor. This will ensure compatibility between versions.

Example:
Correct reference:
stxx.layout.studies["\u200c"+"Aroon"+"\u200c"+" (14)"];
Incorrect reference:
stxx.layout.studies["Aroon (14)"];


outputMap

Properties:
Name Type Description
outputMap object

Mapping between a unique study field name in the dataSet/datSegment and its corresponding general outputs name/color, as set in the study library entry.
This mapping is automatically created and present on all study descriptors, and used by all default study functions to ensure data generated by a calculation function can be found by the display function.
Example:

// Map for an Alligator study with inputs of:
// -Jaw Period:13
// -Jaw Offset:8
// -Teeth Period:8
// -Teeth Offset:5
// -Lips Period:5
// -Lips Offset:3
// -Show Fractals:false

{
	"Jaw ‌Alligator‌ (13,8,8,5,5,3,n)":	"Jaw",
	"Teeth ‌Alligator‌ (13,8,8,5,5,3,n)":	"Teeth",
	"Lips ‌Alligator‌ (13,8,8,5,5,3,n)":	"Lips"
}

outputs

Properties:
Name Type Description
outputs object

Keys for each possible study output with its corresponding rendering color.


panel

Properties:
Name Type Description
panel string

ID of the panel element to which the study is attached.


parameters

Properties:
Name Type Description
parameters object

Keys for each of the study's possible plot parameters.


type

Properties:
Name Type Description
type string

The study type.

Methods


appendFutureTicks(stx, ticks)

Adds extra ticks to the end of the scrubbed array, to be added later to the dataSet.

This function can be used to add extra ticks, like offsets into the future, to the dataSet to be plotted ahead of the current bar. If a DT is not supplied, one will be calculate for each tick in the array.

Remember to call this outside of any loop that iterates through the quotes array, or you will create a never-ending loop, since this increases the array size.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

ticks array

The array of ticks to add. Each tick is an object containing whatever data to add.

Since:
  • 7.3.0

Example
var futureTicks = [];
for (i++; i < quotes.length; i++) {
	var quote = quotes[i];
	if (i + offset >= 0) {
		if (i + offset < quotes.length) quotes[i + offset][name] = quote["Forecast " + sd.name];
		else {
			var ft = {};
			ft[name] = quote["Forecast " + sd.name];
			futureTicks.push(ft);
		}
	}
}
sd.appendFutureTicks(stx, futureTicks);

getContext(stx)

Returns the context to use for drawing the study

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart object

Since:
  • 7.1.0

Returns:

An HTML canvas context

Type
object

getDependents(stx [, followsPanel])

Returns an array of all studies which depend on a given study. A dependent study is one which uses an output of another study as input.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

A chart object

followsPanel boolean <optional>

If true, will only return those studies which are not assigned to an explicit panel

Since:
  • 7.1.0

Returns:

Array of dependent studies

Type
array

getYAxis(stx)

Returns the y-axis used by the study

Parameters:
Name Type Description
stx CIQ.ChartEngine

CIQ.ChartEngine

Since:
  • 7.1.0

Returns:

Y axis

Type
CIQ.ChartEngine.YAxis

undraggable(stx)

Determines whether the study can be dragged to another axis or panel.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart object.

Since:
  • 7.3.0

Returns:

true if not allowed to drag.

Type
boolean