API Reference
Namespaces
Classes
Events
Global
Externals

Namespace: Builtins

CIQ.Scripting. Builtins

Set of functions containing the builtin scripting operators, such as moving average calculations.

Members


sma

sma: compute simple moving average calculation

Same as ma

Methods


cmo()

cmo: compute a Chande Momentum calculation

Examples

cmo for the close with a period of 50

result = stddev("Close", 50);

use built-in to create a Chande Momentum study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the cmo builtin that calculates a Chande Momentum
cmo = cmo(field, period)

plot(cmo, color: "orange")

dataset()

dataset: pull quote values out of the (scrubbed) symbol values

Examples

close from the current quote

close = dataset("Close");

close from the previous quote

close = dataset("Close", -1);

implement a simple moving average

study("Simple MA")
field = input("Field", "field")
period = input("Period", 20)
sum = (length) ->
	total = 0
	while length
		value = dataset(field, -(--length))
		return null if not value?
		total += value
	total
total = sum period
if total?
	average = total / period
	plot average

ema()

ema: compute exponential moving average calculation

Examples

ema for the close with a period of 50

result = ema("Close", 50);

use built-in to create an exponential simple moving average study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the ema builtin that calculates an exponential moving average
ema = ema(field, period)

plot(ema, color: "orange")

fill()

Create parameters for {CIQ.prepareChannelFill}. Store in sd.scriptStates.

Example

Fill the area between two indicator lines

top = dataset("High")
bottom = dataset("Low")

topBand = plot(top)
bottomBand = plot(bottom)

fill(topBand, bottomBand, color: "green")

histogram()

Set the value in the dataset to create a histogram. There can only be a single histogram per study.

Examples

Simple histogram with default colors

histogram(field);

Histogram with custom positive & negative colors

histogram(field, colorPositive: '#01ff01', colorNegative: '#ff0101')

Histogram with custom increasing & decreasing colors

histogram(field, colorIncreasing: '#0101ff', colorDecreasing: '#767600', opacity: 0.4)

ma()

ma: compute a simple moving average calculation

Examples

ma for the close with a period of 50

result = ma("Close", 50);

use built-in to create a complete simple moving average study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the ma builtin that calculates a simple moving average
simple = ma(field, period)

plot(simple, color: "orange")

plot()

plot: plots a line on the chart

Example

plot an orange line for data belonging to field

plot(field, color: "orange")

smma()

smma: compute welles-wilder moving average calculation

Examples

smma for the close with a period of 50

result = smma("Close", 50);

use built-in to create a welles-wilder moving average study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the smma builtin that calculates a welles-wilder moving average
smma = smma(field, period)

plot(smma, color: "orange")

stddev()

stddev: Standard Deviation calculation.

Examples

stddev for the close with a period of 50

result = stddev("Close", 50);

use built-in to create a Standard Deviation study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the stddev builtin that calculates a Standard Deviation
stddev = stddev(field, period)

plot(stddev, color: "orange")

tma()

tma: compute triangular moving average calculation

Examples

tma for the close with a period of 50

result = tma("Close", 50);

use built-in to create a triangular moving average study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the tma builtin that calculates a triangular moving average
tma = tma(field, period)

plot(tma, color: "orange")

tsma()

tsma: compute time-series moving average calculation

Examples

tsma for the close with a period of 50

result = stma("Close", 50);

use built-in to create a time-series moving average study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the tsma builtin that calculates a time-series moving average
tsma = tsma(field, period)

plot(tsma, color: "orange")

vdma()

vdma: compute vidya (based on variable) moving average calculation

Examples

vdma for the close with a period of 50

result = vdma("Close", 50);

use built-in to create a vidya moving average study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the vdma builtin that calculates a vidya moving average
vdma = vdma(field, period)

plot(vdma, color: "orange")

vma()

vma: compute variable moving average calculation

Examples

vma for the close with a period of 50

result = vma("Close", 50);

use built-in to create a variable moving average study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the vma builtin that calculates a variable moving average
vma = vma(field, period)

plot(vma, color: "orange")

wma()

wma: compute weighted moving average calculation

Examples

wma for the close with a period of 50

result = wma("Close", 50);

use built-in to create a weighted moving average study

study("Hello World")
field = input("Field", "Close")

# Define the Period input for the study
period = input("Period", 50)
# Use the wma builtin that calculates a triangular moving average
wma = wma(field, period)

plot(wma, color: "orange")