API Reference
Namespaces
Classes
Events
Global
Externals

Namespace: Scripting

CIQ. Scripting

Namespace for functionality related to study scripting.

Only available if subscribing to the scriptIQ module.

Namespaces

Builtins
Descriptors
Scripts

Methods


<static> addCoffeeScriptStudyToLibrary(script)

Adds an unprocessed script to the studyLibrary.

The study can then be created like any other one on the chart by simply calling CIQ.Studies.addStudy.

Parameters:
Name Type Description
script string

Source code for the script in CoffeeScript, as provided by end user

Since:
  • 6.2.0

Returns:

An object containing {ast, javaScript, studyScript, sd} or error. See CIQ.Scripting.processCoffee

Type
object
Example
var compiledScript = CIQ.Scripting.addCoffeeScriptStudyToLibrary(
	"study('Study2'); field = input('Field', 'field'); value = dataset(field); plusfour = value + 4; plot(plusfour);"
);
CIQ.Studies.addStudy(stxx, compiledScript.sd.name, null, null, null, null, compiledScript.sd);

<static> addStudyToLibrary(script, sd)

Adds a processed script to the studyLibrary.

The study can then be created like any other one on the chart by simply calling CIQ.Studies.addStudy.

Parameters:
Name Type Description
script string

Source code for the script in javaScript, as returned by CIQ.Scripting.processCoffee

sd CIQ.Studies.StudyDescriptor

The study descriptor generated by CIQ.Scripting.processCoffee. This will replace any existing studies in the library with the same name.

Example
var compiledScript = CIQ.Scripting.processCoffee(
	"study('Study2'); field = input('Field', 'field'); value = dataset(field); plusfour = value + 4; plot(plusfour);"
);
CIQ.Scripting.addStudyToLibrary(compiledScript.studyScript, compiledScript.sd);
CIQ.Studies.addStudy(stxx, compiledScript.sd.name, null, null, null, null, compiledScript.sd);

<static> processCoffee(source)

Processes a coffee script for custom scripting.

You can then use CIQ.Scripting.addStudyToLibrary with the returned SD and script to finalize the process.

Parameters:
Name Type Description
source string

Coffee script source code

Returns:

Returns a script descriptor which can be stored or passed to CIQ.Scripting.addStudyToLibrary.
The descriptor object contains the following elements:

  • ast: an ast object (JSON format)
  • studyScript: the transformed study
  • sd: a study descriptor which can be used to add this study to the studyLibrary
  • error will be set if an error occurs.
Type
object
Example
var compiledScript = CIQ.Scripting.processCoffee(
	"study('Study2'); field = input('Field', 'field'); value = dataset(field); plusfour = value + 4; plot(plusfour);"
);
CIQ.Scripting.addStudyToLibrary(compiledScript.studyScript, compiledScript.sd);
CIQ.Studies.addStudy(stxx, compiledScript.sd.name, null, null, null, null, compiledScript.sd);