Everything built into Navy on one page: the language, series and variables, inputs, all ta.* functions, math and text, colors, outputs, drawing objects, collections, Wintrading data, limits, errors.
The language at a glance
Everything built in, counted from the compiler's registry.
The editor's hover help and completion show the same entries with parameters and examples.
All of them keep state between bars: call them at the top level, on every bar (why). Lengths are constants or inputs. A tuple is unpacked with const [a, b, c] = ….
Moving averages
Call
What it does
Gives
ta.sma(source, length)
Simple moving average: the mean of the last length values
float
ta.ema(source, length)
Exponential (alpha = 2 / (length + 1))
float
ta.rma(source, length)
Wilder's (alpha = 1 / length), as in RSI and ATR
float
ta.wma(source, length)
Weighted: linear weights, the newest heaviest
float
ta.vwma(source, length)
Weighted by volume
float
ta.hma(source, length)
Hull moving average
float
ta.alma(source, length, offset = 0.85, sigma = 6)
Arnaud Legoux moving average
float
ta.swma(source)
Symmetric weights over the last 4 values (1/6, 2/6, 2/6, 1/6)
float
ta.linreg(source, length, offset = 0)
Linear regression of the last length values, at offset bars back
float
ta.vwap(source = hlc3)
VWAP, reset at 00:00 UTC every day; also the variable ta.vwap
float
Oscillators
Call
What it does
Gives
ta.rsi(source, length)
Relative strength index, 0…100
float
ta.macd(source, fast, slow, signal)
MACD: the line, its signal line and the histogram
[macd, signal, hist]
ta.stoch(source, high, low, length)
Stochastic %K, 0…100
float
ta.cci(source, length)
Commodity channel index
float
ta.cmo(source, length)
Chande momentum oscillator, −100…100
float
ta.mfi(source, length)
Money flow index, 0…100
float
ta.mom(source, length)
Momentum: source − source[length]
float
ta.roc(source, length)
Rate of change, %
float
ta.tsi(source, shortLength, longLength)
True strength index, −1…1
float
ta.wpr(length)
Williams %R, −100…0
float
ta.cog(source, length)
Center of gravity
float
ta.percentrank(source, length)
Percent of the previous length values at or below the current one
float
Volatility and channels
Call
What it does
Gives
ta.tr(handleNa = false)
True range; also the variable ta.tr
float
ta.atr(length)
Average true range (Wilder's average)
float
ta.stdev(source, length)
Standard deviation of the last length values
float
ta.variance(source, length)
Variance of the last length values
float
ta.dev(source, length)
Mean absolute deviation from the SMA
float
ta.bb(source, length, mult)
Bollinger bands
[middle, upper, lower]
ta.bbw(source, length, mult)
Bollinger band width: (upper − lower) / middle
float
ta.kc(source, length, mult, useTrueRange = true)
Keltner channels (around an EMA)
[middle, upper, lower]
ta.kcw(source, length, mult, useTrueRange = true)
Keltner channel width: (upper − lower) / middle
float
Trend
Call
What it does
Gives
ta.dmi(diLength, adxSmoothing)
Directional movement: +DI, −DI and ADX
[plusDI, minusDI, adx]
ta.sar(start, inc, max)
Parabolic SAR
float
ta.supertrend(factor, atrPeriod)
Supertrend line and direction (< 0 up, > 0 down)
[line, direction]
Windows, sums and volume
Call
What it does
Gives
ta.highest(source, length)
Highest of the last length values, this bar included
float
ta.lowest(source, length)
Lowest of the last length values, this bar included
float
ta.highestbars(source, length)
Offset (0 or negative) to the bar with the highest value
int
ta.lowestbars(source, length)
Offset (0 or negative) to the bar with the lowest value
int
ta.change(source, length = 1)
source − source[length]
float
ta.sum(source, length)
Sum of the last length values
float
ta.cum(source)
Running total since the first bar
float
ta.obv()
On-balance volume; also the variable ta.obv
float
Events and pivots
Call
What it does
Gives
ta.cross(a, b)
a crossed b on this bar, either way
bool
ta.crossover(a, b)
a crossed above b (was ≤, now >)
bool
ta.crossunder(a, b)
a crossed below b (was ≥, now <)
bool
ta.rising(source, length)
Above each of its previous length values
bool
ta.falling(source, length)
Below each of its previous length values
bool
ta.barssince(condition)
Bars since the condition was last true (na before it first was)
int
ta.valuewhen(condition, source, occurrence = 0)
source on the bar where the condition was true, occurrence times back (0: the latest)
float
ta.pivothigh(source, leftbars, rightbars)
The pivot high, reported rightbars bars after it, na elsewhere; its bar is bar_index - rightbars
float
ta.pivotlow(source, leftbars, rightbars)
The pivot low, the same way
float
Math and text: math.*, str.*
Call
What it does
Gives
math.abs(x)
Absolute value
float
math.sqrt(x)
Square root
float
math.pow(base, exponent)
base to the power exponent
float
math.exp(x)
e to the power x
float
math.log(x), math.log10(x)
Natural and base-10 logarithm
float
math.floor(x), math.ceil(x)
Down and up to a whole number
int
math.round(x, precision = 0)
Rounds to precision decimals; the result is a float
Top level only, up to 64. Per bar: the colors of plot, fill, bgcolor and markers, and the values. Constants: plot width and style, hline options, marker text, shape, size and text color, titles, alert messages.
Fills between two plots or hlines; a per-bar color draws a cloud, the top/bottom options a vertical gradient
bgcolor(color, { title })
The bar's background across the pane; na leaves it clear
marker.above(condition, 'text', { color, shape, size, textColor, title })
A shape (and text) over the high of the bars where the condition holds
marker.below(condition, 'text', { … })
The same under the low
marker.at(price, 'text', { … })
A shape at a price, on the bars where it is not na
alert(condition, 'message', { freq, title })
An alert on live bars; freq: 'bar', 'close', 'all'
alertcondition(condition, 'Title', 'message')
A condition for the alerts dialog; silent in Wintrading for now
Drawing objects: line, box, label
x is a bar index (xloc: 'time' — a time in ms), y a price. Everything about an object may change per bar; a method on an na handle does nothing and reads na. Up to 500 of each kind.
Methods are called on the value (a.push(x)) or, as in Pine, through the namespace (array.push(a, x)).
Wintrading data
Columns (vol, liq, oi, fp, book) are per bar with history; walls is a live list (i from 0 to walls.size() - 1). na where there is no data. Where each one has data: Scripts → Data.
Name
What it is
Unit
vol.buy, vol.sell
Aggressive buy / sell volume of the bar (market orders)
coins
vol.delta
vol.buy − vol.sell
coins
liq.long, liq.short
Longs (forced sells) / shorts (forced buys) liquidated in the bar; final once the next bar opens
$
liq.total
liq.long + liq.short
$
oi.open, oi.high, oi.low, oi.close
Open interest at the bar's open, its high and low within the bar, at its close
coins
oi.delta
oi.close − oi.open: positions opened (> 0) or closed (< 0)
coins
oi.usd
oi.close × close
$
fp.buy, fp.sell
Aggressive buys / sells from the bar's clusters
coins
fp.delta, fp.volume
fp.buy − fp.sell, fp.buy + fp.sell
coins
fp.poc
The price where the bar traded the most volume
price
book.bid, book.ask
Resting within 1% below / above the bar's close
$
book.imbalance
(bid − ask) / (bid + ask), from −1 (all asks) to 1 (all bids)
−1 … 1
book.bidWall, book.askWall
Price of the largest bid / ask level
price
book.bidWallSize, book.askWallSize
Its size
$
walls.size()
Number of densities now (0: none, or the symbol is not tracked)
count
walls.price(i), walls.usd(i)
Price and size of density i
price, $
walls.side(i)
1 — a bid (below the price), −1 — an ask (above it)