Skip to main content

Signal

Persistent storage of [symbol->key,value] pairs that can be used for maintaining a state across all functions/tasks. This interface allows storing and querying of key/value pairs of data for each symbol. The current value of a signal will be displayed next to the UI chart. Each signal value has a timestamp assocaited with it. The timestamp of a signal will only change if a value has changed, so in effect, the timestamp represents the date and time when a current value of a signal was last set.

Parameters#

ParameterTypeDescription
symbolStringthe symbol of the ticker in the grid
nameStringthe name of the signal, it will be used to retrieve its value
valueVarianta value of the signal, can be string, a number, or a boolean
colorStringOPTIONAL. Applies to 'visual' signals only such as .Line. Must be a full HTML color value, i.e. '#FFFF00'
typeNumberOPTIONAL. Applies to .Line() only. A bit of an experimental feature. Supported values so far are 1 or 2, and they determine the placement of the label.

Signal.set#

Creates a signal (key/value pair) for a given symbol. If a name already exists, its value will be updated.

Signal.set(symbol, name, value);

Signal.get#

Retrieve the value of a signal (state) for a given symbol.

var value = Signal.get(symbol, name);

Signal.clear#

Clears a signal (state) for a given symbol.

Signal.clear(symbol, name);

Signal.ageOf#

Returns an age of a modified signal: how long ago a value was changed (in milliseconds).

Important note: the age of a signal is not when Signal.set() was called last, but when a value was MODIFIED last with a call to Signal.set(). Multiple calls to Signal.set() with the same value will not result in change .ageOf() value.

var age = Signal.ageOf(symbol, name);
if (age > ONE_MINUTE)
Signal.clear(symbol, name);

Signal.line#

Creates or updates a horizontal markup line (typically indicating a price level). It is one of the few signals with a visual component.

algo trading markup lines

Signal.line('AMC', 'Support Line', 82.25);
//we can also specify a color and a type, valid type values are '1' or '2'
Signal.line('AMC', 'Support Line', 82.25, '#66FF66', 1);
//check the current value of a 'line'
var value = Signal.get('AMC', 'Support Line');

Signal.all#

Returns an array of all signals currently set for a specified symbol.