Skip to content

Globals

These variables and functions are available in every script without imports.

Price Series

NameTypeDescription
openSeriesOpen price
highSeriesHigh price
lowSeriesLow price
closeSeriesClose price
volumeSeriesVolume

Bar Info

NameTypeDescription
bar_indexnumberCurrent bar index (0-based, oldest = 0)
timenumberCurrent bar timestamp (Unix seconds)

Math

The standard Math object is available:

ts
Math.abs(-5)       // 5
Math.max(10, 20)   // 20
Math.min(10, 20)   // 10
Math.sqrt(16)      // 4
Math.round(3.7)    // 4
Math.floor(3.7)    // 3
Math.ceil(3.2)     // 4
Math.pow(2, 10)    // 1024
Math.log(100)      // 4.605
Math.PI            // 3.14159...

Number Utilities

FunctionDescription
isNaN(value)Check if a value is NaN
isFinite(value)Check if a value is finite
parseFloat(string)Parse a string to float
parseInt(string, radix?)Parse a string to integer
NaNNot-a-Number constant
InfinityInfinity constant

Console

ts
console.log('RSI:', rsi[0], 'Bar:', bar_index)

Output goes to the browser developer console (F12).

Multi-Timeframe Data

The request namespace provides access to higher-timeframe OHLCV data:

ts
const daily = request.timeframe('D')
const dailySMA = ta.sma(daily.close, 50)

See Multi-Timeframe (request) for full documentation.

Script Declaration

FunctionDescription
indicator(name, opts?)Declare script as an indicator
strategy(name, opts?)Declare script as a strategy

Options: { overlay?: boolean }true draws on price chart, false in a sub-pane.

Tradify Charts Scripting Documentation