ScriptingReferenceFunction index

Function index

Lipi exposes 154 functions across 7 namespaces, with 338 signatures between them. A function with more than one signature accepts more than one shape of call; the interpreter chooses by the types you pass.

chartPoint

FunctionSummary
chartPoint.copyHands back a copy of a chart point.
chartPoint.from_indexBuilds a chart point from a bar index and a price.
chartPoint.from_timeBuilds a chart point from a time and a price.
chartPoint.newBuilds a chart point with all three of its fields given: a time, a bar index and a price.
chartPoint.nowBuilds a chart point from a price alone: it takes no time and no bar index, and even the price is optional.

color

FunctionSummary
color.aReads the opacity of a colour.
color.bReads the blue component of a colour.
color.gReads the green component of a colour.
color.newTakes a colour and an opacity, and returns that colour at that opacity.
color.rReads the red component back out of a colour.
color.rgbBuilds a colour from red, green and blue components, with an optional opacity.

input

FunctionSummary
input.boolOffers the reader a true-or-false setting and hands back what they chose.
input.colorAsks the reader for a colour.
input.floatThe decimal counterpart of input.int, with the same nine arguments and const float in place of const int.
input.intA whole-number setting, with optional bounds and an optional increment.
input.priceA price setting. The value comes back as a float.
input.sessionAsks the reader for a session and gives you back a string.
input.sourceLets the reader pick which series the script reads — the close, the high, a midpoint, and so on.
input.stringA one-line text setting.
input.text_areaA multi-line text setting, for a message or a note rather than a single word.
input.timeA time setting, returned as an int.
input.timeframeAsks the reader for a timeframe. The answer arrives as a string.

math

FunctionSummary
math.absThe absolute value of number: its magnitude, with the sign removed.
math.acosThe arccosine of angle, in radians.
math.asinThe arcsine of angle, in radians.
math.atanThe arctangent of angle, in radians.
math.avgThe arithmetic mean of the numbers you pass: their sum divided by how many there are.
math.ceilThe smallest whole number that is not less than number.
math.cosThe cosine of angle, where the angle is in radians.
math.expEuler’s number raised to the power of number.
math.floorThe largest whole number that is not greater than number.
math.logThe natural logarithm of number: its logarithm to base e.
math.maxThe largest of the numbers you pass.
math.minThe smallest of the numbers you pass.
math.powbase raised to the power of exponent.
math.randomGives your script a random float, bounded below by min and above by max.
math.roundRounds number to the nearest whole number and returns an int.
math.signThe sign of number: -1 for a negative number and 1 for a positive one.
math.sinThe sine of angle, where the angle is in radians.
math.sqrtThe square root of number.
math.sumThe sum of the numbers you pass.
math.tanThe tangent of angle, where the angle is in radians.
math.todegreesConverts an angle in radians to the same angle in degrees.
math.toradiansConverts an angle in degrees to the same angle in radians.

orderflow

FunctionSummary
orderflow.cvdCumulative volume delta. On each bar it adds that bar’s delta - the balance of buying against selling, taken as at the bar’s close - to a running total, and hands you that total as one whole number per bar.

str

FunctionSummary
str.containsTests whether one string occurs inside another.
str.endswithAsks whether a string finishes with a given ending.
str.format_timeRenders a time value as text.
str.lengthGives the length of a string as an int.
str.lowerConverts a string to lower case.
str.matchReturns the first part of source that matches the regular expression pattern.
str.posReports the position at which one string sits inside another.
str.repeatProduces a string made of repeated copies of another, with the option of something between the copies.
str.replaceSubstitutes one piece of text for another inside a string.
str.replace_allSubstitutes new text for every occurrence of the old text.
str.startswithThe counterpart of str.endswith, looking at the front of the string instead of the back.
str.substringCuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone.
str.tonumberReads a number out of a string.
str.tostringRenders a value as a string. One overload takes a number and one takes a bool.
str.trimRemoves whitespace from around a string and hands back the result.
str.upperConverts a string to upper case; the other half of the pair with str.lower.

talib

FunctionSummary
talib.almaAn Arnaud Legoux moving average of source over length bars.
talib.atrAverage true range over length bars. Read it as a measure of how far the market has been travelling, not as a price level.
talib.barssinceCounts the bars that have gone by since condition was last true.
talib.bbBollinger bands for source over length bars, with mult setting how far the outer bands sit from the middle one.
talib.bbwBollinger band width: the same calculation as talib.bb, delivered as one number instead of three bands.
talib.cciCommodity Channel Index for source over length bars.
talib.changeThe difference between the current value of source and its value length bars back.
talib.cmoChande Momentum Oscillator for source over length bars.
talib.cogCentre of gravity of source across a window of length bars.
talib.correlationCorrelation between two series, source1 and source2, measured over length bars.
talib.crossTrue on a bar where source1 and source2 cross, in either direction.
talib.crossoverFlags the bar on which source1 crosses above source2. Crosses the other way are ignored.
talib.crossunderThe mirror of talib.crossover: true on the bar where source1 crosses below source2.
talib.cumAccumulates source as the script advances through the chart.
talib.dcDonchian channel over length bars.
talib.dcwDonchian channel width over length bars, as a single figure.
talib.devA deviation measure for source over length bars.
talib.dmiThe directional movement family in one call, calculated from the chart’s own bars.
talib.emaExponential moving average of source over length bars, weighted so that recent bars count for more than older ones.
talib.fallingAsks the same question as talib.rising in the other direction: has source been falling across length bars?
talib.highestThe highest value source reached in the last length bars.
talib.highestbarsLocates the highest value of source within the last length bars and returns its position rather than its value.
talib.hmaHull moving average of source over length bars.
talib.kcKeltner channels for source over length bars, with mult setting the distance to the outer bands.
talib.kcwKeltner channel width for source over length bars: one figure in place of the three the channel call returns.
talib.linregFits a linear regression to source across length bars and returns a value from that fit.
talib.lowestThe lowest value source reached in the last length bars.
talib.lowestbarsGives the position of the lowest value of source within the last length bars, not the value itself.
talib.macdMoving average convergence/divergence for source, from three lengths: fastlen, slowlen and siglen.
talib.medianThe middle value of the last length values of source.
talib.mfiMoney Flow Index for source over length bars.
talib.modeOf the last length values of source, this reports the one that recurs most often.
talib.nviNegative volume index for the chart’s bars.
talib.obvOn-balance volume for the chart’s bars.
talib.percentile_linear_interpolationThe requested percentile of source over length bars, interpolating between the two values that straddle the rank.
talib.percentile_nearest_rankTakes the requested percentile of source over length bars at the nearest rank, without interpolating.
talib.percentrankRanks where source now stands against the last length bars of itself.
talib.pivothighFinds a pivot high — a bar that stands above leftBars bars on one side and rightBars bars on the other.
talib.pivotlowThe low-side counterpart to talib.pivothigh: a bar that stands below leftBars bars on one side and rightBars on the other.
talib.psarParabolic SAR, controlled by three numbers rather than a bar count: where the calculation starts, how much it moves on each step, and how far it is allowed to go.
talib.pviPositive volume index for the chart’s bars, the counterpart of talib.nvi.
talib.pvtPrice-volume trend for the chart’s bars.
talib.rangeHow much ground source covered over the last length bars, expressed as one figure.
talib.risingTests whether source has been rising across length bars.
talib.rmaRolling moving average of source over length bars.
talib.rocRate of change of source measured across length bars.
talib.rsiRelative Strength Index for source over length bars.
talib.smaSimple moving average of source over length bars: every bar in the window counts for the same.
talib.stdevStandard deviation of source over length bars.
talib.stochStochastic reading that places source inside the span set by high and low over length bars.
talib.sumAdds up the last length values of source.
talib.supertrendSupertrend from a multiplier and an atrLength, calculated on the chart’s own bars.
talib.swmaSymmetrically weighted moving average of source.
talib.trTrue range for the bar the script is on, taken from the chart’s own bars.
talib.tsiTrue Strength Index for source, smoothed by two lengths, r and s.
talib.valuewhenReads source from the bar on which condition was true, going back as far as occurrence says.
talib.varianceVariance of source over length bars.
talib.vwapVolume-weighted average price built on source.
talib.vwmaVolume-weighted moving average of source over length bars: bars that traded more count for more.
talib.wmaWeighted moving average of source over length bars.
talib.wprWilliams %R over length bars.
talib.wvadWilliams variable accumulation/distribution over length bars, calculated on the chart’s own bars.

Global functions

FunctionSummary
alertRaises an alert from inside your own logic, with a message you build.
alertconditionDeclares a condition the platform can offer to the reader. It raises nothing by itself.
barcolorRecolours the chart’s own price bars. It draws no value of its own.
bgcolorShades the pane’s background. Like barcolor it adds no value to the chart.
boolA true-or-false value. The two constants true and false are the literals for it.
colorA colour. You can write one directly as a hex literal — six digits for the colour, eight to carry alpha as well.
dayofmonthThe day of the month of the bar being evaluated.
dayofweekThe day of the week of the bar being evaluated.
fillShades the band between two plots, or between two horizontal lines. It has two forms and no mixed one, so you cannot fill between a plot and a level, and like the other output calls it must sit at the top level.
fixnanTakes a series and hands back a series of the same type, with na values dealt with.
floatA number with a fractional part, written 1.5. It has no fields.
hlineThe value hline gives back once it has drawn a horizontal level.
hourThe hour of the bar being evaluated.
indicatorDeclares the script and names it. Put it first.
inputEleven functions, one per kind of setting the reader can change from the chart: bool, colour, float, int, price, session, source, string, text area, time and timeframe.
intA whole number. One of the five data types the grammar names directly.
minuteThe minute of the bar being evaluated.
monthThe month of the bar being evaluated.
naTests whether a value is absent. It takes any type and gives back a bool.
nzTakes a value and an alternative of the same type, and stands in for the value where it is absent.
plotThe value plot gives back once it has drawn a series.
plotarrowDraws an arrow on each bar, sized from a number you supply.
plotbarDraws bars from the same four required series that plotcandle takes.
plotcandleDraws candles from four series of your own rather than from the chart’s bars.
plotcharThe same marker as plotshape, with one character in place of a shape from the fixed set.
plotshapeMarks the bars on which a condition holds, using a shape from a fixed set.
secondThe second of the bar being evaluated.
stringA piece of text, written between double quotes: "length".
timestampAssembles a time from its parts - the other direction from the eight functions that take a time apart.
weekofyearThe week of the year of a time you supply.
yearThe year of the bar being evaluated.
Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade