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
| Function | Summary |
|---|---|
chartPoint.copy | Hands back a copy of a chart point. |
chartPoint.from_index | Builds a chart point from a bar index and a price. |
chartPoint.from_time | Builds a chart point from a time and a price. |
chartPoint.new | Builds a chart point with all three of its fields given: a time, a bar index and a price. |
chartPoint.now | Builds a chart point from a price alone: it takes no time and no bar index, and even the price is optional. |
color
| Function | Summary |
|---|---|
color.a | Reads the opacity of a colour. |
color.b | Reads the blue component of a colour. |
color.g | Reads the green component of a colour. |
color.new | Takes a colour and an opacity, and returns that colour at that opacity. |
color.r | Reads the red component back out of a colour. |
color.rgb | Builds a colour from red, green and blue components, with an optional opacity. |
input
| Function | Summary |
|---|---|
input.bool | Offers the reader a true-or-false setting and hands back what they chose. |
input.color | Asks the reader for a colour. |
input.float | The decimal counterpart of input.int, with the same nine arguments and const float in place of const int. |
input.int | A whole-number setting, with optional bounds and an optional increment. |
input.price | A price setting. The value comes back as a float. |
input.session | Asks the reader for a session and gives you back a string. |
input.source | Lets the reader pick which series the script reads — the close, the high, a midpoint, and so on. |
input.string | A one-line text setting. |
input.text_area | A multi-line text setting, for a message or a note rather than a single word. |
input.time | A time setting, returned as an int. |
input.timeframe | Asks the reader for a timeframe. The answer arrives as a string. |
math
| Function | Summary |
|---|---|
math.abs | The absolute value of number: its magnitude, with the sign removed. |
math.acos | The arccosine of angle, in radians. |
math.asin | The arcsine of angle, in radians. |
math.atan | The arctangent of angle, in radians. |
math.avg | The arithmetic mean of the numbers you pass: their sum divided by how many there are. |
math.ceil | The smallest whole number that is not less than number. |
math.cos | The cosine of angle, where the angle is in radians. |
math.exp | Euler’s number raised to the power of number. |
math.floor | The largest whole number that is not greater than number. |
math.log | The natural logarithm of number: its logarithm to base e. |
math.max | The largest of the numbers you pass. |
math.min | The smallest of the numbers you pass. |
math.pow | base raised to the power of exponent. |
math.random | Gives your script a random float, bounded below by min and above by max. |
math.round | Rounds number to the nearest whole number and returns an int. |
math.sign | The sign of number: -1 for a negative number and 1 for a positive one. |
math.sin | The sine of angle, where the angle is in radians. |
math.sqrt | The square root of number. |
math.sum | The sum of the numbers you pass. |
math.tan | The tangent of angle, where the angle is in radians. |
math.todegrees | Converts an angle in radians to the same angle in degrees. |
math.toradians | Converts an angle in degrees to the same angle in radians. |
orderflow
| Function | Summary |
|---|---|
orderflow.cvd | Cumulative 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
| Function | Summary |
|---|---|
str.contains | Tests whether one string occurs inside another. |
str.endswith | Asks whether a string finishes with a given ending. |
str.format_time | Renders a time value as text. |
str.length | Gives the length of a string as an int. |
str.lower | Converts a string to lower case. |
str.match | Returns the first part of source that matches the regular expression pattern. |
str.pos | Reports the position at which one string sits inside another. |
str.repeat | Produces a string made of repeated copies of another, with the option of something between the copies. |
str.replace | Substitutes one piece of text for another inside a string. |
str.replace_all | Substitutes new text for every occurrence of the old text. |
str.startswith | The counterpart of str.endswith, looking at the front of the string instead of the back. |
str.substring | Cuts a piece out of a string. There are two forms: one takes a start and an end, the other takes a start alone. |
str.tonumber | Reads a number out of a string. |
str.tostring | Renders a value as a string. One overload takes a number and one takes a bool. |
str.trim | Removes whitespace from around a string and hands back the result. |
str.upper | Converts a string to upper case; the other half of the pair with str.lower. |
talib
| Function | Summary |
|---|---|
talib.alma | An Arnaud Legoux moving average of source over length bars. |
talib.atr | Average true range over length bars. Read it as a measure of how far the market has been travelling, not as a price level. |
talib.barssince | Counts the bars that have gone by since condition was last true. |
talib.bb | Bollinger bands for source over length bars, with mult setting how far the outer bands sit from the middle one. |
talib.bbw | Bollinger band width: the same calculation as talib.bb, delivered as one number instead of three bands. |
talib.cci | Commodity Channel Index for source over length bars. |
talib.change | The difference between the current value of source and its value length bars back. |
talib.cmo | Chande Momentum Oscillator for source over length bars. |
talib.cog | Centre of gravity of source across a window of length bars. |
talib.correlation | Correlation between two series, source1 and source2, measured over length bars. |
talib.cross | True on a bar where source1 and source2 cross, in either direction. |
talib.crossover | Flags the bar on which source1 crosses above source2. Crosses the other way are ignored. |
talib.crossunder | The mirror of talib.crossover: true on the bar where source1 crosses below source2. |
talib.cum | Accumulates source as the script advances through the chart. |
talib.dc | Donchian channel over length bars. |
talib.dcw | Donchian channel width over length bars, as a single figure. |
talib.dev | A deviation measure for source over length bars. |
talib.dmi | The directional movement family in one call, calculated from the chart’s own bars. |
talib.ema | Exponential moving average of source over length bars, weighted so that recent bars count for more than older ones. |
talib.falling | Asks the same question as talib.rising in the other direction: has source been falling across length bars? |
talib.highest | The highest value source reached in the last length bars. |
talib.highestbars | Locates the highest value of source within the last length bars and returns its position rather than its value. |
talib.hma | Hull moving average of source over length bars. |
talib.kc | Keltner channels for source over length bars, with mult setting the distance to the outer bands. |
talib.kcw | Keltner channel width for source over length bars: one figure in place of the three the channel call returns. |
talib.linreg | Fits a linear regression to source across length bars and returns a value from that fit. |
talib.lowest | The lowest value source reached in the last length bars. |
talib.lowestbars | Gives the position of the lowest value of source within the last length bars, not the value itself. |
talib.macd | Moving average convergence/divergence for source, from three lengths: fastlen, slowlen and siglen. |
talib.median | The middle value of the last length values of source. |
talib.mfi | Money Flow Index for source over length bars. |
talib.mode | Of the last length values of source, this reports the one that recurs most often. |
talib.nvi | Negative volume index for the chart’s bars. |
talib.obv | On-balance volume for the chart’s bars. |
talib.percentile_linear_interpolation | The requested percentile of source over length bars, interpolating between the two values that straddle the rank. |
talib.percentile_nearest_rank | Takes the requested percentile of source over length bars at the nearest rank, without interpolating. |
talib.percentrank | Ranks where source now stands against the last length bars of itself. |
talib.pivothigh | Finds a pivot high — a bar that stands above leftBars bars on one side and rightBars bars on the other. |
talib.pivotlow | The low-side counterpart to talib.pivothigh: a bar that stands below leftBars bars on one side and rightBars on the other. |
talib.psar | Parabolic 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.pvi | Positive volume index for the chart’s bars, the counterpart of talib.nvi. |
talib.pvt | Price-volume trend for the chart’s bars. |
talib.range | How much ground source covered over the last length bars, expressed as one figure. |
talib.rising | Tests whether source has been rising across length bars. |
talib.rma | Rolling moving average of source over length bars. |
talib.roc | Rate of change of source measured across length bars. |
talib.rsi | Relative Strength Index for source over length bars. |
talib.sma | Simple moving average of source over length bars: every bar in the window counts for the same. |
talib.stdev | Standard deviation of source over length bars. |
talib.stoch | Stochastic reading that places source inside the span set by high and low over length bars. |
talib.sum | Adds up the last length values of source. |
talib.supertrend | Supertrend from a multiplier and an atrLength, calculated on the chart’s own bars. |
talib.swma | Symmetrically weighted moving average of source. |
talib.tr | True range for the bar the script is on, taken from the chart’s own bars. |
talib.tsi | True Strength Index for source, smoothed by two lengths, r and s. |
talib.valuewhen | Reads source from the bar on which condition was true, going back as far as occurrence says. |
talib.variance | Variance of source over length bars. |
talib.vwap | Volume-weighted average price built on source. |
talib.vwma | Volume-weighted moving average of source over length bars: bars that traded more count for more. |
talib.wma | Weighted moving average of source over length bars. |
talib.wpr | Williams %R over length bars. |
talib.wvad | Williams variable accumulation/distribution over length bars, calculated on the chart’s own bars. |
Global functions
| Function | Summary |
|---|---|
alert | Raises an alert from inside your own logic, with a message you build. |
alertcondition | Declares a condition the platform can offer to the reader. It raises nothing by itself. |
barcolor | Recolours the chart’s own price bars. It draws no value of its own. |
bgcolor | Shades the pane’s background. Like barcolor it adds no value to the chart. |
bool | A true-or-false value. The two constants true and false are the literals for it. |
color | A colour. You can write one directly as a hex literal — six digits for the colour, eight to carry alpha as well. |
dayofmonth | The day of the month of the bar being evaluated. |
dayofweek | The day of the week of the bar being evaluated. |
fill | Shades 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. |
fixnan | Takes a series and hands back a series of the same type, with na values dealt with. |
float | A number with a fractional part, written 1.5. It has no fields. |
hline | The value hline gives back once it has drawn a horizontal level. |
hour | The hour of the bar being evaluated. |
indicator | Declares the script and names it. Put it first. |
input | Eleven 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. |
int | A whole number. One of the five data types the grammar names directly. |
minute | The minute of the bar being evaluated. |
month | The month of the bar being evaluated. |
na | Tests whether a value is absent. It takes any type and gives back a bool. |
nz | Takes a value and an alternative of the same type, and stands in for the value where it is absent. |
plot | The value plot gives back once it has drawn a series. |
plotarrow | Draws an arrow on each bar, sized from a number you supply. |
plotbar | Draws bars from the same four required series that plotcandle takes. |
plotcandle | Draws candles from four series of your own rather than from the chart’s bars. |
plotchar | The same marker as plotshape, with one character in place of a shape from the fixed set. |
plotshape | Marks the bars on which a condition holds, using a shape from a fixed set. |
second | The second of the bar being evaluated. |
string | A piece of text, written between double quotes: "length". |
timestamp | Assembles a time from its parts - the other direction from the eight functions that take a time apart. |
weekofyear | The week of the year of a time you supply. |
year | The 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.