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 callta.atr(length)→ float · keeps state per callta.barssince(condition)→ int · keeps state per callta.bb(series, length, mult)→ tuple of 3 · keeps state per callta.bbw(series, length, mult)→ float · keeps state per callta.cci(source, length)→ float · keeps state per callta.change(source, length?)→ float · keeps state per callta.cog(source, length)→ float · keeps state per callta.correlation(source1, source2, length)→ float · keeps state per callta.cross(source1, source2)→ bool · keeps state per callta.crossover(source1, source2)→ bool · keeps state per callta.crossunder(source1, source2)→ bool · keeps state per callta.cum(source)→ float · keeps state per callta.dev(source, length)→ float · keeps state per callta.dmi(diLength, adxSmoothing)→ tuple of 3 · keeps state per callta.ema(source, length)→ float · keeps state per callta.falling(source, length)→ bool · keeps state per callta.highest(source?, length)→ float · keeps state per callta.highestbars(source?, length)→ int · keeps state per callta.hma(source, length)→ float · keeps state per callta.kc(series, length, mult, useTrueRange?)→ tuple of 3 · keeps state per callta.kcw(series, length, mult, useTrueRange?)→ float · keeps state per callta.linreg(source, length, offset)→ float · keeps state per callta.lowest(source?, length)→ float · keeps state per callta.lowestbars(source?, length)→ int · keeps state per callta.macd(source, fastlen, slowlen, siglen)→ tuple of 3 · keeps state per callta.median(source, length)→ float · keeps state per callta.mfi(series, length)→ float · keeps state per callta.mom(source, length)→ float · keeps state per callta.percentrank(source, length)→ float · keeps state per callta.pivothigh(source?, leftbars, rightbars)→ float · keeps state per callta.pivotlow(source?, leftbars, rightbars)→ float · keeps state per callta.range(source, length)→ float · keeps state per callta.rising(source, length)→ bool · keeps state per callta.rma(source, length)→ float · keeps state per callta.roc(source, length)→ float · keeps state per callta.rsi(source, length)→ float · keeps state per callta.sar(start, inc, max)→ float · keeps state per callta.sma(source, length)→ float · keeps state per callta.stdev(source, length, biased?)→ float · keeps state per callta.stoch(source, high, low, length)→ float · keeps state per callta.supertrend(factor, atrPeriod)→ tuple of 2 · keeps state per callta.swma(source)→ float · keeps state per callta.tr(handle_na?)→ float · keeps state per callta.tsi(source, short_length, long_length)→ float · keeps state per callta.valuewhen(condition, source, occurrence)→ float · keeps state per callta.variance(source, length, biased?)→ float · keeps state per callta.vwap(source)→ float · keeps state per callta.vwma(source, length)→ float · keeps state per callta.wma(source, length)→ float · keeps state per callta.wpr(length)→ float · keeps state per call
math
math.abs(number)→ floatmath.acos(number)→ floatmath.asin(number)→ floatmath.atan(number)→ floatmath.avg(number0, …)→ floatmath.ceil(number)→ intmath.cos(number)→ floatmath.exp(number)→ floatmath.floor(number)→ intmath.log(number)→ floatmath.log10(number)→ floatmath.max(number0, …)→ floatmath.min(number0, …)→ floatmath.pow(base, exponent)→ floatmath.random(min?, max?, seed?)→ float · keeps state per callmath.round(number, precision?)→ floatmath.round_to_mintick(number)→ floatmath.sign(number)→ floatmath.sin(number)→ floatmath.sqrt(number)→ floatmath.sum(source, length)→ float · keeps state per callmath.tan(number)→ floatmath.todegrees(number)→ floatmath.toradians(number)→ float
str
str.contains(source, str)→ boolstr.format(formatString, …)→ stringstr.length(string)→ intstr.tostring(value, format?)→ string
color
color.b(color)→ floatcolor.from_gradient(value, bottom_value, top_value, bottom_color, top_color)→ colorcolor.g(color)→ floatcolor.new(color, transp)→ colorcolor.r(color)→ floatcolor.rgb(red, green, blue, transp?)→ colorcolor.t(color)→ float
Inputs
input(defval, title?, tooltip?, inline?, group?, confirm?, display?, options?, minval?, maxval?, step?)→ anyinput.bool(defval, title?, tooltip?, inline?, group?, confirm?, display?)→ boolinput.color(defval, title?, tooltip?, inline?, group?, confirm?, display?)→ colorinput.float(defval, title?, minval?, maxval?, step?, tooltip?, inline?, group?, confirm?, display?, options?)→ floatinput.int(defval, title?, minval?, maxval?, step?, tooltip?, inline?, group?, confirm?, display?, options?)→ intinput.source(defval, title?, tooltip?, inline?, group?, confirm?, display?)→ floatinput.string(defval, title?, options?, tooltip?, inline?, group?, confirm?, display?)→ stringinput.timeframe(defval, title?, options?, tooltip?, inline?, group?, confirm?, display?)→ string
Outputs
alertcondition(condition, title?, message?)→ voidbarcolor(color, offset?, show_last?, title?, display?)→ voidAccepted, no effect: editable
bgcolor(color, offset?, show_last?, title?, display?)→ voidAccepted, no effect: editable
fill(hline1, hline2, color?, title?, display?)→ voidAccepted, no effect: editable, fillgaps
hline(price, title?, color?, linestyle?, linewidth?, display?)→ handleAccepted, no effect: editable
plot(series, title?, color?, linewidth?, style?, histbase?, offset?, show_last?, display?)→ handleAccepted, no effect: trackprice, join, editable, format, precision
plotarrow(series, title?, colorup?, colordown?, offset?, show_last?, display?)→ voidAccepted, no effect: minheight, maxheight, editable, format, precision
plotchar(series, title?, char?, location?, color?, offset?, text?, textcolor?, size?, show_last?, display?)→ voidAccepted, no effect: editable, format, precision
plotshape(series, title?, style?, location?, color?, offset?, text?, textcolor?, size?, show_last?, display?)→ voidAccepted, no effect: editable, format, precision
General
bool(x)→ boolfixnan(source)→ float · keeps state per callfloat(x)→ floatint(x)→ intna(x)→ boolnz(source, replacement?)→ any
Built-in variables
bar_indexseries intbarstate.isconfirmedseries boolbarstate.isfirstseries boolbarstate.islastseries boolcloseseries floathighseries floathl2series floathlc3series floathlcc4series floatlast_bar_indexseries intlowseries floatohlc4series floatopenseries floatsyminfo.minticksimple floatsyminfo.tickersimple stringta.accdistseries floatta.obvseries floatta.trseries floatta.vwapseries floattimeseries inttime_closeseries inttimeframe.periodsimple stringvolumeseries 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()