Namespace: Studies

CIQ. Studies

Namespace for functionality related to studies (aka indicators)

Classes

DialogHelper

Members


actualOutputs :Array

Array of study outputs which should be considered valid fields in the study dialog "Field" dropdown". This is autopopulated from CIQ.Studies.displayStudies.

Type:
  • Array

DEFAULT_INPUTS

Constants for when no inputs or outputs specified in studies. Values can be changed but do not change keys.


prettify :Object

Used to reduce certain common fields to abbreviated form for display in study panel labels

Type:
  • Object

studyLibrary :Object

The studyLibrary defines all of the available studies. This is used to drive the dialog boxes and creation of the studies. When you create a custom study you should add it to the studyLibrary.

You can also alter study defaults by overriding the different elements on each definition. For example, if you wanted to change the default colors for the volume underlay, you would add the following code in your files; making sure your files are loaded after the library js files -- not before:

CIQ.Studies.studyLibrary["vol undr"].outputs= {"Up Volume":"blue","Down Volume":"yellow"};

See Using and Customizing Studies for complete details

Type:
  • Object
Example
"RAVI": {
			"name": "RAVI",
			"seriesFN": CIQ.Studies.displayRAVI,
			"calculateFN": CIQ.Studies.calculatePriceOscillator,
			"inputs": {"Field":"field", "Short Cycle":7, "Long Cycle":65},
			"outputs": {"Increasing Bar":"#00DD00", "Decreasing Bar":"#FF0000"},
			"parameters": {
				template:"studyOverZones",
				init:{studyOverZonesEnabled:true, studyOverBoughtValue:3, studyOverBoughtColor:"auto", studyOverSoldValue:-3, studyOverSoldColor:"auto"}
			},
			"attributes":{
				"studyOverBoughtValue":{"min":0,"step":"0.1"},
				"studyOverSoldValue":{"max":0,"step":"0.1"}
			}
		},

studyPanelMap :Object

Maps the names of studies to the panel that they are drawn on. For instance, a moving average may be drawn on an RSI panel

Type:
  • Object

Methods


addStudy(stx, type [, inputs] [, outputs] [, parameters] [, panelName] [, study])

Adds or replace a study on the chart. A layout change event is triggered when this occurs.

Example:

Optionally you can assign the edit callback to a function that can handle initialization of a dialog box for editing studies. If the callback is not assigned a function, the edit study buttons/functionality will not appear. The 'Study Edit' feature is standard functionality in the advanced package.

Prior to version 2015-07-01, all edit functionality was handled by stx.editCallback and was limited to panel studies. Starting on version 2015-07-01, edit functionality is handled by stxx.callbacks.studyPanelEdit and stxx.callbacks.studyOverlayEdit; and it is available on both panel studies and overly studies. See Examples for exact function parameters and return value requirements. Please note that these callbacks must be set before you call importLayout. Otherwise your imported studies will not have an edit capability.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

The chart object

type string

The name of the study (object key on the CIQ.Studies.studyLibrary)

inputs object <optional>

Inputs for the study instance. Default is those defined in the studyLibrary. Note that if you specify this object, it will be combined with (override) the library defaults. To bypass a library default, set that field to null.

Properties
Name Type Argument Description
id string <optional>

The id of the current study. If set, then the old study will be replaced

display string <optional>

The display name of the current study. If not set, a name generated by CIQ.Studies.prettyDisplay will be used. Note that if the study descriptor defines a display name, the study descriptor name will allays override this parameter.

outputs object <optional>

Outputs for the study instance. Default is those defined in the studyLibrary. Values specified here will override those in the studyLibrary.

parameters object <optional>

Additional custom parameters for this study if supported or required by that study. Default is those defined in the CIQ.Studies.studyLibrary.

Properties
Name Type Argument Description
replaceID object <optional>

If inputs.id is specified, this value can be used to set the new ID for the modified study( will display as the study name on the study panel). If omitted the existing ID will be preserved.

panelName string <optional>

Optionally specify the panel. The relationship between studies and their panels is kept in CIQ.Studies.studyPanelMap. If not specified then an attempt will be made to locate a panel based on the input id or otherwise created if required.

study object <optional>

Optionally supply a study definition, overriding what may be found in the study library

Since:
  • 3.0.0 added study argument
Returns:

A study descriptor which can be used to remove or modify the study.

Type
object
Examples
CIQ.Studies.addStudy(stxx, "vol undr", {}, {"Up Volume":"#8cc176","Down Volume":"#b82c0c"});
// this is an example of  the expected stxx.editCallback function for version prior to version 2015-07-01
stxx.editCallback=function(stx, sd){
	// your code here
	return $$("studyDialog"); // This is a reference to the actual HTML dialog container that can be filled by studyDialog.
};
var params={stx:stx,sd:sd,inputs:inputs,outputs:outputs, parameters:parameters};
stxx.callbacks.studyPanelEdit=function(params){
		// your code here
};
var params={stx:stx,sd:sd,inputs:inputs,outputs:outputs, parameters:parameters};
stxx.callbacks.studyOverlayEdit=function(params){
		// your code here
};

calculateCorrelationCoefficient(stx, sd)

Calculate function for correlation coefficient

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd object

Study Descriptor

Version:
  • ChartIQ Advanced Package

calculateGenericEnvelope(stx, sd, percentShift [, centerIndex] [, offsetIndex], pointShift)

Calculate function for preparing data to be used by displayChannel(). Inserts the following fields in the dataSet: quote[sd.type + " Top " + sd.name]=quote[centerIndex]+totalShift;
quote[sd.type + " Bottom " + sd.name]=quote[centerIndex]-totalShift;
quote[sd.type + " Median " + sd.name]=quote[centerIndex];
quote["Bandwidth " + sd.name]=200totalShift/quote[centerIndex];
quote["%b " + sd.name]=50
((quote.Close-quote[centerIndex])/totalShift+1);
Example: 'Prime Bands' + ' Top ' + 'Prime Number Bands (true)'.

Parameters:
Name Type Argument Default Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor

percentShift object

Used to calculate totalShift. Defaults to 0 (zero)

centerIndex object <optional>
Close

Quote element to use for center series (Open, Close, High, Low). Defaults to "Close"

offsetIndex object <optional>
centerIndex

Quote element to use for calculating totalShift (percentShift*quote[offsetIndex]+pointShift;)

pointShift object

Used to calculate totalShift.Defaults to 0 (zero)


calculateKlinger(stx, sd)

Calculate function for klinger

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor


calculateMACD(stx, sd)

Calculate function for MACD study

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor


calculateMinMaxForDataPoint(stx, name, quotes)

Convenience function for determining the min and max for a given data point

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart

name string

The field to evaluate

quotes array

The array of quotes to evaluate (typically dataSet, scrubbed or dataSegment)

Returns:

Object containing the min and max data point values

Type
minMax

calculateMovingAverage(stx, sd)

Calculate function for moving averages. sd.inputs["Type"] can be used to request a specific type of moving average.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

sd studyDescriptor

A study descriptor

Returns:
Type
undefined

calculateMovingAverageExponential(stx, sd)

Calculate function for exponential moving average

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor


calculateMovingAverageTimeSeries(stx, sd)

Calculate function for time series moving average

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor


calculateMovingAverageTriangular(stx, sd)

Calculate function for triangular moving average

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor


calculateMovingAverageVariable(stx, sd)

Calculate function for variable moving average and VI Dynamic MA (VIDYA)

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor


calculatePriceRelative(stx, sd)

Calculates data for Price Relative Study

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd object

The study descriptor object

Version:
  • ChartIQ Advanced Package

calculateRSI(stx, sd)

A sample study calculation function. Note how sd.chart.scrubbed is used instead of dataSet. Also note the naming convention for the outputs.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

sd studyDescriptor

A study descriptor


calculateStandardDeviation(stx, sd)

Calculate function for standard deviation.

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor


calculateStochastics(stx, sd)

Calculate function for stochastics

Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor


calculateValuationLines(stx, sd, quotes)

Calculate "val lines" study. This study does all calculations on the {studyDescriptor.chart.dataSegment}.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

sd studyDescriptor

A study descriptor

quotes Array.<Object>

the dataSegment


calculateVolume(stx, sd)

A simple calculation function. Volume is already obtained, so all that is done here is setting colors.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

sd studyDescriptor

Study to calculate volume for


createHistogram(stx, sd, quotes, centered [, opacity])

Draws a histogram on the study. Initial bar color is defined in stx-chart.css under '.stx_histogram'. If using the default UI, refer to provided css files under '.stx_histogram' and '.ciq-night .stx_histogram' style sections. If sd.outputs["Decreasing Bar"] and sd.outputs["Increasing Bar"] are present, their corresponding colors will be used instead.

Note the convention to use sd.name+"_hist" for histogram values on a study

Parameters:
Name Type Argument Default Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

quotes array

The quotes (dataSegment)

centered boolean

If true then the histogram will be physically centered on the yAxis, otherwise it will be centered at the zero value on the yAxis

opacity number <optional>
1

Optionally set the opacity


createVolumeChart(stx, sd, quotes)

Creates a volume chart. If no volume is available on the screen then the panel will be watermarked "Volume Not Available" (translated if a translate function is attached to the kernel object). Each bar width will be determined by widthFactor study parameter.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

sd studyDescriptor

A study descriptor

quotes array

Array of quotes

Example
// default study library entry with required parameters
		"volume": {
			"name": "Volume Chart",
		    "range": "0 to max",
		    "yAxis": {"ground":true, "initialMarginTop":0},
		    "seriesFN": CIQ.Studies.createVolumeChart,
		    "calculateFN": CIQ.Studies.calculateVolume,
		    "inputs": {},
		    "outputs": {"Up Volume":"#8cc176","Down Volume":"#b82c0c"},
		    "parameters": {
		    	"zoom": 0,
		    	"widthFactor":1
		    }
		}

createYAxis(stx, sd, quotes, panel)

Creates the yAxis for a study panel. Utilizes CIQ.ChartEngine.createYAxis internally. This method is not re-entrant. panel.axisDrawn will be set to true in order to prevent the yAxis from being drawn multiple times if there are multiple studies on a panel. The first study on the panel will therefore determine the minimum and maximum bounds of the panel. If the library entry defines a yAxisFN function then it will be used to render the yaxis instead of CIQ.ChartEngine.createYAxis. If zones are enabled then CIQ.ChartEngine.createYAxis again will not be the renderer.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

quotes array

The set of quotes (representing dataSegment)

panel CIQ.ChartEngine.Panel

A reference to the panel


determineMinMax(stx, sd, quotes)

Method to determine the minimum and maximum points in a study panel. The studyLibrary is checked for the type of range. If the range is dynamic then the output values for the study are checked for minimum and maximum values. If a histogram is being printed then the values for the histogram (represented by sd.name+"_hist") are also checked. This method does not draw the yAxis but it does compute the high, low and shadow that the yAxis utilizes when drawn.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

quotes array

The set of quotes to evaluate


displayChannel(stx, sd, quotes)

Rendering function for displaying a Channel study output composed of top, middle and bottom lines.

Requires study library input of "Channel Fill":true to determine if the area within the channel is to be shaded. Shading will be done using the "xxxxx Channel" or "xxxxx Median" color defined in the outputs parameter of the study library.

Requires study library outputs to have fields in the format of :

  • 'xxxxx Top' or 'xxxxx High' for the top band,
  • 'xxxxx Bottom' or 'xxxxx Low' for the bottom band and
  • 'xxxxx Median' or 'xxxxx Channel' for the middle line.

It expects 'quotes' to have fields for each series in the channel with keys in the following format:

  • study-output-name ( from study library) + " " + sd.name.
  • Example: 'Prime Bands Top'+ ' ' + 'Prime Number Bands (true)'. Which equals : 'Prime Bands Top Prime Number Bands (true)'
Parameters:
Name Type Description
stx CIQ.ChartEngine

Chart object

sd studyDescriptor

Study Descriptor

quotes array

The array of quotes needed to render the channel

Since:
  • 4.1.0 now shading is rendered under the channel lines instead of over.
Examples
"inputs": {"Period":5, "Shift": 3, "Field":"field", "Channel Fill":true}
"outputs": {"Prime Bands Top":"red", "Prime Bands Bottom":"auto", "Prime Bands Channel":"rgb(184,44,11)"}
// full definition example including opacity
		"Bollinger Bands": {
			"name": "Bollinger Bands",
			"overlay": true,
			"calculateFN": CIQ.Studies.calculateBollinger,
			"seriesFN": CIQ.Studies.displayChannel,
			"inputs": {"Field":"field", "Period":20, "Standard Deviations": 2, "Moving Average Type":"ma", "Channel Fill": true},
			"outputs": {"Bollinger Bands Top":"auto", "Bollinger Bands Median":"auto", "Bollinger Bands Bottom":"auto"},
			"attributes": {
				"Standard Deviations":{min:0.1,step:0.1}
			},
			"parameters": {
				"init":{opacity: 0.2}
			}
		}

displayError(stx, sd [, params])

This method displays a watermark on a panel for a study with sd.error set. The sd.error property can be set to true, which will display the default message "Not enough data to compute XXX" or it can be set to a custom string which will be displayed as supplied.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

The charting object

sd studyDescriptor

The study descriptor

params Object <optional>

additional options to customize the watermark

Properties
Name Type Argument Description
panel string <optional>

name of the panel on which to display the error, defaults to sd.panel

h string <optional>

watermark horizontal position

v string <optional>

watermark vertical position

Since:

  • • 3.0.0
    • 4.0.0 Displays one error per panel, added params argument

displayHistogramWithSeries(stx, sd, quotes)

A sample of a custom display function. This function creates the yAxis, draws a single histogram and then plots the series. Note that to differentiate between a regular series and the histogram series there is a convention to use sd.name+"_hist" for histogram values on a study See CIQ.Studies.createHistogram for details

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

quotes array

The quotes (dataSegment)


displayIndividualSeriesAsLine(stx, sd, panel, name, quotes)

Displays multiple data-points as series on a panel. This is the default display function for an indicator and will work for 90% of custom indicators. It also inserts the study results into the studyPanelMap to be selected as the basis for another study.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

panel CIQ.ChartEngine.Panel

A reference to the study panel

name string

The name of this study instance (should match field from 'quotes' needed to render this line)

quotes array

The array of quotes (dataSegment)


displayPSAR2(stx, sd, quotes)

A sample display function for an overlay. An overlay displays in the chart area.

Also note the use of clipping to ensure that the overlay doesn't print outside of the panel

Finally note that when color=="auto" you can use stx.defaultColor which will automatically adjust based on the background color. This is the default for studies that use the color picker for user selection of output colors.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

sd studyDescriptor
quotes array

Array of quotes


displaySeriesAsHistogram(stx, sd, quotes)

Displays a single or group of series as histogram in the study panel. It expects the 'quotes' array to have data fields for each series with keys in the outputMap format: 'output name from study library'+ " " + sd.name.

It takes into account the following study input fields (see CIQ.ChartEngine#drawHistogram for details ) :

  • sd.inputs.HistogramType ("overlaid", "clustered", "stacked") - Default "overlaid"
  • sd.inputs.HeightPercentage - Default ".25"
  • sd.inputs.WidthFactor - Default ".5"
Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

quotes array

The set of quotes (dataSegment)

Example
// this adds a study panel that will display the High and Low values from the masterData as a stacked histogram study
		CIQ.Studies.studyLibrary["Plot High Low"]={
		 	"seriesFN": CIQ.Studies.displaySeriesAsHistogram,
		 	inputs:{"HistogramType":"stacked"},
		    outputs:{"High":"blue","Low":"red"}
		};
		CIQ.Studies.addStudy(stxx, "Plot High Low");

displaySeriesAsLine(stx, sd, quotes)

Displays a single or group of series as lines in the study panel. One series per output field declared in the study library will be displayed. It expects the 'quotes' array to have data fields for each series with keys in the outputMap format: 'output name from study library'+ " " + sd.name. Y-axis will be rendered if studyOverZones are not set and panel is not “hidden”. studyOverZones will be displayed and Peaks & Valleys will be filled if corresponding thresholds are set in the study library as follows:

init:{studyOverZonesEnabled:true, studyOverBoughtValue:70, studyOverBoughtColor:"auto", studyOverSoldValue:30, studyOverSoldColor:"auto"}

For most custom studies this function will do the work for you.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

quotes array

The set of quotes (dataSegment)


displayStudies(stx, chart [, underlays])

Animation Loop This method displays all of the studies for a chart. It is called from within the chart draw() loop.

Parameters:
Name Type Argument Default Description
stx CIQ.ChartEngine

The charting object

chart CIQ.ChartEngine.Chart

Which chart to display studies for

underlays Boolean <optional>
false

If set to true then underlays only will be displayed, otherwise underlays will be skipped


displayValuationLines(stx, sd)

Display "val lines" study.

It is possible to change how the lines appear with CSS styling. Example: .ciq-valuation-average-line { border-style: solid; border-width: 1.2px; opacity: 0.95; } .ciq-valuation-deviation-line { border-style: dotted; border-width: 1px; opacity: 0.80; }

These values are used to create the params argument for {CIQ.ChartEngine#plotLine}.

  • "border-style" -> "pattern"
  • "border-width" -> "lineWidth"
  • "opacity" -> "opacity"

Average line defaults to {pattern: 'solid', lineWidth: 1, opacity: 1} Deviation lines default to {pattern: 'dashed', lineWidth: 1, opacity: 1}

Suggested that whitespace be set from about 60 to 90 pixels so that the labels are clearly visible in the home position.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

Examples
var stxx = new CIQ.ChartEngine({container: $('.chart-container')[0], preferences: {whitespace: 60.5}});

Alternatively, you can use yAxis labels by setting the labels parameter to "yaxis" in the studyLibrary entry.
CIQ.Studies.studyLibrary['val lines'].parameters = {labels: 'yaxis'};

drawHorizontal(stx, sd, quotes, price)

Draws a horizontal line on the study.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

quotes array

The array of quotes (unused)

price number

The price (value) to draw the horizontal line


drawZones(stx, sd, quotes)

Plots over/under zones for indicators that support them, and when the user selects them. This method will draw its own yAxis which will not have a scale, but merely the over under points. Shading will be performed between the zone lines and the study plot.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

quotes array

The quotes (dataSegment)


generateID(stx, studyName, inputs [, replaceID])

Automatically generates a unique name for the study instance. If a translation callback has been associated with the chart object then the name of the study will be translated.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

A chart engine instance

studyName string

Type of study

inputs object

The inputs for this study instance

replaceID string <optional>

If it matches then return the same id

Returns:

A unique name for the study

Type
string

getFieldInputs(sd)

Returns an array of input field names which are used to specify the field for the study. In most cases, this field is called "Field", but it does not have to be, nor does there need to be only one.

Parameters:
Name Type Description
sd studyDescriptor

The study descriptor

Since:
  • 3.0.0
Returns:

Input fields used to specify the field

Type
array

getStudyList(excludeList)

Function to determine which studies are available.

Parameters:
Name Type Description
excludeList object

Exclusion list of studies in object form ( e.g. {"rsi":true,"macd":true})

Since:
  • 3.0.0
Returns:

Map of avaialbe entries from CIQ.Studies.studyLibrary.

Type
object

initializeFN(stx, type, inputs, outputs [, parameters] [, panelName] [, study])

The default initialize function for a study. It creates the study descriptor. It creates the panel if one is required.

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

The chart object

type string

The type of study (from studyLibrary)

inputs object

The inputs for the study instance

outputs object

The outputs for the study instance

parameters object <optional>

Optional parameters if required or supported by this study

panelName string <optional>

Optional panel. If not provided then the panel will be determined dynamically.

study object <optional>

Optionally supply a study definition to use in lieu of the study library entry

Since:
  • 3.0.0 added study argument
Returns:

The newly initialized study descriptor

Type
object

initializeStochastics(stx, type, inputs, outputs)

A sample of a custom initialization function. It is rare that one would be required. In this case we simply customize the input display but otherwise call the default.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

type *

Type to pass to initialization function

inputs object

Study inputs

outputs object

Study ouptuts

Returns:

Initialization callback's data

Type
*

initPriceRelative(stx, type, inputs, outputs, parameters, panel)

Initializes data for Price Relative Study by fetching the comparing symbol.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

type string

Study type

inputs object

Study inputs

outputs object

Study outputs

parameters object

Study parameters

panel string

ID of the study's panel element

Version:
  • ChartIQ Advanced Package
Since:
  • 09-2016-19
Returns:

Study descriptor object

Type
studyDescriptor

MA(type, periods, field, offset, name, stx, sd)

Moving Average convenience function

Parameters:
Name Type Description
type string

The type of moving average, e.g. simple, exponential, triangular, etc

periods number

Moving average period

field string

The field in the data array to perform the moving average on

offset number

Periods to offset the result by

name string

String to prefix to the name of the output. Full name of output would be name + " " + sd.name, for instance "Signal MACD"

stx CIQ.ChartEngine

Chart object

sd object

Study Descriptor

Since:
  • 04-2015

movingAverageHelper(stx, input)

Does conversions for valid moving average types

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

input string

String to test if a moving average type or "options" to return the list of ma options.

Returns:

The name of the moving average or a list of options

Type
Object

prettyDisplay(id)

Convert a study ID into a displayable format

Parameters:
Name Type Description
id string

The ID

Returns:

A pretty (shortened) ID

Type
string

removeStudy(stx, sd)

Removes a study from the chart (and panel if applicable)

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart object

sd studyDescriptor

A study descriptor returned from CIQ.Studies.addStudy


removeStudySymbols(sd, stx)

Removes any series that the study is referencing

Parameters:
Name Type Description
sd object

Study descriptor

stx CIQ.ChartEngine

The chart engine

Since:
  • 3.0.7 added required stx argument

replaceStudy(stx, id, type [, inputs] [, outputs] [, parameters] [, panelName] [, study])

Replaces an existing study with new inputs, outputs and parameters. When using this method a study's position in the stack will remain the same. Derived (child) studies will shift to use the new study as well

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

The chart object

id string

The id of the current study. If set, then the old study will be replaced

type string

The name of the study (out of the studyLibrary)

inputs object <optional>

Inputs for the study instance. Default is those defined in the studyLibrary.

outputs object <optional>

Outputs for the study instance. Default is those defined in the studyLibrary.

parameters object <optional>

additional custom parameters for this study if supported or required by that study

panelName string <optional>

Optionally specify the panel. If not specified then an attempt will be made to locate a panel based on the input id or otherwise created if required.

study object <optional>

Optionally supply a study definition, overriding what may be found in the study library

Since:
  • 3.0.0 added study argument
Returns:

A study descriptor which can be used to remove or modify the study.

Type
object

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

A study descriptor contains all of the information necessary to handle a study. READ ONLY.

Do not 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


volumeChart(stx, sd, colorMap, borderMap)

Convenience function for creating a volume style chart that supports multiple colors of volume bars. If borderMap (border colors) is passed in then the chart will display in a format where bars are flush against one another so that there is no white space between bars. If however a borderMap is not specified then white space will be left between the bars.

Parameters:
Name Type Description
stx CIQ.ChartEngine

The chart object

sd studyDescriptor

The study descriptor

colorMap object

Map of colors to arrays. Each array should contain entries for each dataSegment bar mapped to that color. It should contain null values for any bar that shouldn't be drawn

borderMap object

Map of border colors for each color. If null then no borders will be drawn.

Example
var colorMap={};
colorMap["#FF0000"]=[56,123,null,null,45];
colorMap["#00FF00"]=[null,null,12,13,null];

var borderMap={
   "#FF0000": "#FFFFFF",
   "#00FF00": "#FFFFDD"
};
CIQ.Studies.volumeChart(stx, sd, colorMap, borderMap);

volUnderlay(stx, sd, quotes)

Creates a volume underlay for the chart. The underlay height is a % of the chart height as determined by the HeightPercentage study parameter. Each bar width will be determined by widthFactor study parameter.

Parameters:
Name Type Description
stx CIQ.ChartEngine

A chart engine instance

sd studyDescriptor

A study descriptor

quotes array

Array of quotes

Deprecated:
Example
// default study library entry with required parameters
		"vol undr": {
			"name": "Volume Underlay",
			"underlay": true,
		    "seriesFN": CIQ.Studies.createVolumeChart,
		    "calculateFN": CIQ.Studies.calculateVolume,
		    "inputs": {},
		    "outputs": {"Up Volume":"#8cc176","Down Volume":"#b82c0c"},
			"customRemoval": true,
			"removeFN": function(stx, sd){
					stx.layout.volumeUnderlay=false;
					stx.changeOccurred("layout");
				},
		    "parameters": {
		    	"init":{heightPercentage: 0.25},
		    	"widthFactor":1
			}
		}