Chart

Pine-lite reference

Pine-lite runs a subset of Pine Script v5/v6 in your browser.

110 functions · 23 variables · generated from the engine

Scripts run on the candles the chart loaded, in a worker in your browser. Anything not listed fails with an error that names it. Pine Script is a trademark of TradingView.

Functions

Declaration

  • indicator(title, shorttitle?, overlay?, format?, precision?, …)→ void

ta: technical analysis

  • ta.alma(source, length, offset, sigma, floor?)→ float · keeps state per call
  • ta.atr(length)→ float · keeps state per call
  • ta.barssince(condition)→ int · keeps state per call
  • ta.bb(series, length, mult)→ tuple of 3 · keeps state per call
  • ta.bbw(series, length, mult)→ float · keeps state per call
  • ta.cci(source, length)→ float · keeps state per call
  • ta.change(source, length?)→ float · keeps state per call
  • ta.cog(source, length)→ float · keeps state per call
  • ta.correlation(source1, source2, length)→ float · keeps state per call
  • ta.cross(source1, source2)→ bool · keeps state per call
  • ta.crossover(source1, source2)→ bool · keeps state per call
  • ta.crossunder(source1, source2)→ bool · keeps state per call
  • ta.cum(source)→ float · keeps state per call
  • ta.dev(source, length)→ float · keeps state per call
  • ta.dmi(diLength, adxSmoothing)→ tuple of 3 · keeps state per call
  • ta.ema(source, length)→ float · keeps state per call
  • ta.falling(source, length)→ bool · keeps state per call
  • ta.highest(source?, length)→ float · keeps state per call
  • ta.highestbars(source?, length)→ int · keeps state per call
  • ta.hma(source, length)→ float · keeps state per call
  • ta.kc(series, length, mult, useTrueRange?)→ tuple of 3 · keeps state per call
  • ta.kcw(series, length, mult, useTrueRange?)→ float · keeps state per call
  • ta.linreg(source, length, offset)→ float · keeps state per call
  • ta.lowest(source?, length)→ float · keeps state per call
  • ta.lowestbars(source?, length)→ int · keeps state per call
  • ta.macd(source, fastlen, slowlen, siglen)→ tuple of 3 · keeps state per call
  • ta.median(source, length)→ float · keeps state per call
  • ta.mfi(series, length)→ float · keeps state per call
  • ta.mom(source, length)→ float · keeps state per call
  • ta.percentrank(source, length)→ float · keeps state per call
  • ta.pivothigh(source?, leftbars, rightbars)→ float · keeps state per call
  • ta.pivotlow(source?, leftbars, rightbars)→ float · keeps state per call
  • ta.range(source, length)→ float · keeps state per call
  • ta.rising(source, length)→ bool · keeps state per call
  • ta.rma(source, length)→ float · keeps state per call
  • ta.roc(source, length)→ float · keeps state per call
  • ta.rsi(source, length)→ float · keeps state per call
  • ta.sar(start, inc, max)→ float · keeps state per call
  • ta.sma(source, length)→ float · keeps state per call
  • ta.stdev(source, length, biased?)→ float · keeps state per call
  • ta.stoch(source, high, low, length)→ float · keeps state per call
  • ta.supertrend(factor, atrPeriod)→ tuple of 2 · keeps state per call
  • ta.swma(source)→ float · keeps state per call
  • ta.tr(handle_na?)→ float · keeps state per call
  • ta.tsi(source, short_length, long_length)→ float · keeps state per call
  • ta.valuewhen(condition, source, occurrence)→ float · keeps state per call
  • ta.variance(source, length, biased?)→ float · keeps state per call
  • ta.vwap(source)→ float · keeps state per call
  • ta.vwma(source, length)→ float · keeps state per call
  • ta.wma(source, length)→ float · keeps state per call
  • ta.wpr(length)→ float · keeps state per call

math

  • math.abs(number)→ float
  • math.acos(number)→ float
  • math.asin(number)→ float
  • math.atan(number)→ float
  • math.avg(number0, …)→ float
  • math.ceil(number)→ int
  • math.cos(number)→ float
  • math.exp(number)→ float
  • math.floor(number)→ int
  • math.log(number)→ float
  • math.log10(number)→ float
  • math.max(number0, …)→ float
  • math.min(number0, …)→ float
  • math.pow(base, exponent)→ float
  • math.random(min?, max?, seed?)→ float · keeps state per call
  • math.round(number, precision?)→ float
  • math.round_to_mintick(number)→ float
  • math.sign(number)→ float
  • math.sin(number)→ float
  • math.sqrt(number)→ float
  • math.sum(source, length)→ float · keeps state per call
  • math.tan(number)→ float
  • math.todegrees(number)→ float
  • math.toradians(number)→ float

str

  • str.contains(source, str)→ bool
  • str.format(formatString, …)→ string
  • str.length(string)→ int
  • str.tostring(value, format?)→ string

color

  • color.b(color)→ float
  • color.from_gradient(value, bottom_value, top_value, bottom_color, top_color)→ color
  • color.g(color)→ float
  • color.new(color, transp)→ color
  • color.r(color)→ float
  • color.rgb(red, green, blue, transp?)→ color
  • color.t(color)→ float

Inputs

  • input(defval, title?, tooltip?, inline?, group?, confirm?, display?, options?, minval?, maxval?, step?)→ any
  • input.bool(defval, title?, tooltip?, inline?, group?, confirm?, display?)→ bool
  • input.color(defval, title?, tooltip?, inline?, group?, confirm?, display?)→ color
  • input.float(defval, title?, minval?, maxval?, step?, tooltip?, inline?, group?, confirm?, display?, options?)→ float
  • input.int(defval, title?, minval?, maxval?, step?, tooltip?, inline?, group?, confirm?, display?, options?)→ int
  • input.source(defval, title?, tooltip?, inline?, group?, confirm?, display?)→ float
  • input.string(defval, title?, options?, tooltip?, inline?, group?, confirm?, display?)→ string
  • input.timeframe(defval, title?, options?, tooltip?, inline?, group?, confirm?, display?)→ string

Outputs

  • alertcondition(condition, title?, message?)→ void
  • barcolor(color, offset?, show_last?, title?, display?)→ void

    Accepted, no effect: editable

  • bgcolor(color, offset?, show_last?, title?, display?)→ void

    Accepted, no effect: editable

  • fill(hline1, hline2, color?, title?, display?)→ void

    Accepted, no effect: editable, fillgaps

  • hline(price, title?, color?, linestyle?, linewidth?, display?)→ handle

    Accepted, no effect: editable

  • plot(series, title?, color?, linewidth?, style?, histbase?, offset?, show_last?, display?)→ handle

    Accepted, no effect: trackprice, join, editable, format, precision

  • plotarrow(series, title?, colorup?, colordown?, offset?, show_last?, display?)→ void

    Accepted, no effect: minheight, maxheight, editable, format, precision

  • plotchar(series, title?, char?, location?, color?, offset?, text?, textcolor?, size?, show_last?, display?)→ void

    Accepted, no effect: editable, format, precision

  • plotshape(series, title?, style?, location?, color?, offset?, text?, textcolor?, size?, show_last?, display?)→ void

    Accepted, no effect: editable, format, precision

General

  • bool(x)→ bool
  • fixnan(source)→ float · keeps state per call
  • float(x)→ float
  • int(x)→ int
  • na(x)→ bool
  • nz(source, replacement?)→ any

Built-in variables

  • bar_index series int
  • barstate.isconfirmed series bool
  • barstate.isfirst series bool
  • barstate.islast series bool
  • close series float
  • high series float
  • hl2 series float
  • hlc3 series float
  • hlcc4 series float
  • last_bar_index series int
  • low series float
  • ohlc4 series float
  • open series float
  • syminfo.mintick simple float
  • syminfo.ticker simple string
  • ta.accdist series float
  • ta.obv series float
  • ta.tr series float
  • ta.vwap series float
  • time series int
  • time_close series int
  • timeframe.period simple string
  • volume series float

Constants

colorcolor.aqua color.black color.blue color.fuchsia color.gray color.green color.lime color.maroon color.navy color.olive color.orange color.purple color.red color.silver color.teal color.white color.yellow

displaydisplay.all display.none

formatformat.inherit format.mintick format.percent format.price format.volume

hlinehline.style_dashed hline.style_dotted hline.style_solid

locationlocation.abovebar location.absolute location.belowbar location.bottom location.top

mathmath.e math.phi math.pi math.rphi

plotplot.style_area plot.style_circles plot.style_columns plot.style_cross plot.style_histogram plot.style_line plot.style_linebr plot.style_stepline

shapeshape.arrowdown shape.arrowup shape.circle shape.cross shape.diamond shape.flag shape.labeldown shape.labelup shape.square shape.triangledown shape.triangleup shape.xcross

sizesize.auto size.huge size.large size.normal size.small size.tiny

Not supported in v1

  • strategy() and strategy.*Order simulation is not in v1; use indicator() and plotshape() for signals
  • request.security and request.*Other symbols and timeframes; Pine-lite runs on the chart's own candles
  • library, import, exportLibraries are not in v1
  • type (user-defined types), methodNot in v1
  • array.*, matrix.*, map.*Collections are not in v1
  • line.*, label.*, box.*, table.*, polyline.*, linefill.*Drawing objects; use plot, plotshape, hline, fill or bgcolor
  • varipAll bars are historical in v1
  • timeframe.* except timeframe.periodOnly the chart timeframe is known
  • syminfo.* except ticker and mintickOnly syminfo.ticker and syminfo.mintick are supplied
  • plotcandle, plotbar, alert()Not in v1; alertcondition() is listed in the panel
  • plot.style_steplinebr, plot.style_areabr and other break stylesSupported styles: line, linebr, stepline, histogram, columns, circles, cross, area
  • Gradient fill(top_value, bottom_value, ...)fill() takes two plots or two hlines and one colour
  • Pine v4 and older (study(), no ta. namespace)Use //@version=5 or 6 and indicator()
Offline