AlphaChart

AlphaScript Reference

AlphaScript reference

Everything a script can use. Names are matched loosely, so each language can write them its own way: case and underscores do not matter (ta.highest_bars is ta.highestBars, Color.RED is color.red), and C++ and Java may write ta::sma.

The script

The script’s own settings.

indicator(title: string, overlay: bool = false, precision?: int, short?: string)

Names the script and says where it draws: on the price chart (overlay: true) or in its own pane.

indicator("Golden cross", overlay: true)

state(initial: any) → any

Starts a value that is kept from bar to bar (JavaScript and Python): let count = state(0).

Bar data

The bar the script is running on. Each value also has a history: close[1] is the previous bar’s close.

NameKindWhat it is
opennumberThe bar’s opening price.
highnumberThe bar’s highest price.
lownumberThe bar’s lowest price.
closenumberThe bar’s closing price (the last price while the bar is open).
volumenumberThe bar’s volume.
hl2number(high + low) / 2
hlc3number(high + low + close) / 3
ohlc4number(open + high + low + close) / 4
hlcc4number(high + low + 2 × close) / 4
timenumberThe bar’s opening time, in milliseconds since 1970 (UTC).
buyVolumenumberVolume bought at the ask (taker buys), where the exchange reports it; na elsewhere.
sellVolumenumberVolume sold at the bid (taker sells), where the exchange reports it; na elsewhere.
deltanumberBuy volume minus sell volume (order flow delta), where the exchange reports it.
barIndexnumberThe bar’s number: 0 for the oldest loaded bar.
barCountintHow many bars are loaded.
isFirstBarboolTrue on the oldest loaded bar.
isLastBarboolTrue on the newest bar.

Symbol

What the chart is showing.

NameKindWhat it is
symbol.namestringThe symbol as the chart shows it: BTCUSDT, AAPL, EURUSD.
symbol.tickerstringThe exchange’s own code for the symbol.
symbol.exchangestringThe exchange or data source: BINANCE, NASDAQ, BIST …
symbol.typestringcrypto, stock, forex, index, futures, commodity …
symbol.currencystringThe currency prices are in.
symbol.tickSizenumberThe smallest price step.

Time and interval

When a bar is, in the chart’s time zone, and how long one bar lasts.

NameKindWhat it is
timeframe.secondsintSeconds in one bar (a day is 86400).
timeframe.minutesnumberMinutes in one bar.
timeframe.textstringThe interval as the chart writes it: 1m, 15m, 1h, 1D …
timeframe.isIntradayboolBars shorter than a day.
timeframe.isDailyboolDaily bars.
timeframe.isWeeklyboolWeekly bars.
timeframe.isMonthlyboolMonthly bars.

date.year(t?: number) → int

The year of a time (the bar’s time when left out), in the chart’s time zone.

date.month(t?: number) → int

Month, 1 to 12.

date.day(t?: number) → int

Day of the month, 1 to 31.

date.weekday(t?: number) → int

Day of the week: 1 Monday … 7 Sunday.

date.hour(t?: number) → int

Hour, 0 to 23.

date.minute(t?: number) → int

Minute, 0 to 59.

date.second(t?: number) → int

Second, 0 to 59.

date.format(t?: number, pattern: string = "yyyy-MM-dd HH:mm") → string

A time as text. yyyy year, MM month, dd day, HH hour, mm minute, ss second.

print(date.format(time, "dd.MM.yyyy HH:mm"))

date.isNewDay() → bool

True on the first bar of each day (chart time zone).

Inputs

Fields in the indicator’s settings. The user changes them there; the script reads the value.

input.int(title: string, default: int, min?: int, max?: int, step?: int) → int

A whole number the user sets in the indicator’s settings.

Also: input.integer

let length = input.int("Length", 14, min: 1, max: 500)

input.float(title: string, default: number, min?: number, max?: number, step?: number) → number

A number the user sets in the settings.

Also: input.double · input.number · input.decimal

let mult = input.float("Multiplier", 2.0, step: 0.1)

input.bool(title: string, default: bool) → bool

An on/off switch in the settings.

Also: input.boolean

let showBands = input.bool("Show bands", true)

input.string(title: string, default: string, options?: list) → string

A text, or a choice from a list when options are given.

Also: input.text

let kind = input.string("Average", "EMA", options: ["SMA", "EMA", "WMA"])

input.source(title: string, default: number = close) → number

A price to work on (open, high, low, close, hl2, hlc3, ohlc4, hlcc4, volume), chosen in the settings.

let src = input.source("Source", close)

input.color(title: string, default: color) → color

A colour the user picks in the settings.

let lineColor = input.color("Line", #2962ff)

Plots

Values drawn on every bar.

plot(value: number, title?: string, color?: color, width: int = 1, style: string = "line", offset: int = 0) → plot

Draws a value on every bar. Styles: line, step, histogram, columns, circles, cross, area. Gives a handle for fill().

plot(ta.ema(close, 21), "EMA 21", color: #ff9800, width: 2)

hline(price: number, title?: string, color?: color, style: string = "dashed", width: int = 1) → plot

A horizontal line across the pane at a price (an overbought level, a target).

hline(70, "Overbought", color: #f23645)

fill(a: plot, b: plot, color?: color, title?: string, colorDown?: color)

Colours the area between two plots or two horizontal lines. With colorDown, the colour depends on which is on top.

fill(fastPlot, slowPlot, color: color.alpha(color.green, 0.2), colorDown: color.alpha(color.red, 0.2))

bgcolor(color: color, title?: string)

Colours the background of the bar (na: no colour).

bgcolor(close > open ? color.alpha(color.green, 0.1) : na)

Marks and drawings

Marks on bars; labels, lines and boxes you can change later through the handle they give back.

mark(text: string = "", position: string = "above", shape?: string, color?: color, textColor?: color, size: string = "normal", price?: number)

Puts a mark on the bar: above or below it, or at a price. Shapes: triangleUp, triangleDown, arrowUp, arrowDown, circle, square, diamond, cross, xcross, flag, none.

if ta.crossover(fast, slow) {
  mark("Buy", position: "below", shape: "triangleUp", color: color.green)
}

label(text: string, price: number = close, at: int = barIndex, color?: color, textColor?: color, style: string = "down", size: string = "normal") → label

A text bubble at a bar and price. Keep the handle to change or remove it later. Styles: up, down, left, right, center, none (text only).

state last = na
if isLastBar {
  last = label("Close " + str(close), close)
}

line(x1: int, y1: number, x2: int, y2: number, color?: color, width: int = 1, style: string = "solid", extend: string = "none") → line

A line from (bar x1, price y1) to (bar x2, price y2). extend: none, left, right, both.

line(barIndex - 20, low[20], barIndex, low, color: color.blue)

box(left: int, top: number, right: int, bottom: number, color?: color, fill?: color, text: string = "", textColor?: color, extend: bool = false) → box

A rectangle between two bars and two prices (a range, a zone). color is the border, fill the inside.

box(barIndex - 10, ta.highest(high, 10), barIndex, ta.lowest(low, 10), fill: color.alpha(color.blue, 0.1))

Alerts and the console

Telling you something: an alert, or a line in the editor’s console.

alert(message: string, when: bool = true)

Raises an alert on the newest bar while the script is on an open chart: a notice in the app (with a sound when sounds are on) and a system notification if allowed. Once per bar per call.

alert("RSI is above 70", when: ta.rsi(close, 14) > 70)

print(…values: any)

Writes values to the editor’s console (on every bar it runs on; the last 500 lines are kept).

Also: console.log · console.info · console.warn · console.error · System.out.println · System.err.println · puts (C, C++)

if isLastBar {
  print("Last close:", close)
}

printf(format: string, …values: any)

Writes formatted text to the console: %d whole number, %f number, %.2f two decimals, %s text.

Also: System.out.printf

Technical analysis

Calculations with a memory. Each place a ta.* function is called from keeps its own, so call them on every bar, outside if blocks, and use the results inside.

ta.sma(source: number, length: int) → number

Simple moving average: the average of the last length values.

plot(ta.sma(close, 50), "SMA 50")

ta.ema(source: number, length: int) → number

Exponential moving average (newer values weigh more).

plot(ta.ema(close, 21))

ta.rma(source: number, length: int) → number

Wilder’s moving average (RMA / SMMA), as used in RSI and ATR.

ta.wma(source: number, length: int) → number

Weighted moving average (linearly heavier towards the newest value).

ta.vwma(source: number, length: int) → number

Volume-weighted moving average.

ta.hma(source: number, length: int) → number

Hull moving average: smooth and quick.

ta.dema(source: number, length: int) → number

Double exponential moving average.

ta.tema(source: number, length: int) → number

Triple exponential moving average.

ta.alma(source: number, length: int, offset: number = 0.85, sigma: number = 6) → number

Arnaud Legoux moving average.

ta.linreg(source: number, length: int, offset: int = 0) → number

The end of a straight line fitted to the last length values (least squares).

ta.rsi(source: number, length: int = 14) → number

Relative strength index, 0 to 100.

let r = ta.rsi(close, 14)

ta.macd(source: number = close, fast: int = 12, slow: int = 26, signal: int = 9) → [macd, signal, histogram]

MACD line, its signal line and the histogram between them.

let [m, s, h] = ta.macd(close, 12, 26, 9)

ta.stoch(length: int = 14, smoothK: int = 3, smoothD: int = 3) → [k, d]

Stochastic oscillator: %K and its average %D.

let [k, d] = ta.stoch(14, 3, 3)

ta.cci(source: number = hlc3, length: int = 20) → number

Commodity channel index.

ta.mfi(length: int = 14) → number

Money flow index, 0 to 100 (price and volume).

ta.wpr(length: int = 14) → number

Williams %R, -100 to 0.

ta.tr() → number

True range of the bar.

ta.atr(length: int = 14) → number

Average true range: how much the price moves per bar.

let stop = close - 2 * ta.atr(14)

ta.bb(source: number = close, length: int = 20, mult: number = 2) → [middle, upper, lower]

Bollinger bands: an average and lines mult standard deviations above and below.

let [mid, up, lo] = ta.bb(close, 20, 2)

ta.kc(source: number = close, length: int = 20, mult: number = 2, atrLength: int = 10) → [middle, upper, lower]

Keltner channels: an EMA and lines mult ATRs above and below.

ta.dc(length: int = 20) → [middle, upper, lower]

Donchian channels: the highest high and lowest low of the window.

ta.supertrend(factor: number = 3, atrLength: int = 10) → [value, direction]

Supertrend line and its direction: 1 up, -1 down.

let [st, dir] = ta.supertrend(3, 10)

ta.vwap(source: number = hlc3, anchor: string = "session") → number

Volume-weighted average price, starting again each session (UTC day), week or month.

ta.obv() → number

On-balance volume.

ta.dmi(diLength: int = 14, adxLength: int = 14) → [plus, minus, adx]

Directional movement: +DI, -DI and ADX.

ta.adx(length: int = 14) → number

Average directional index: how strong the trend is.

ta.mom(source: number, length: int = 10) → number

Momentum: the value minus the value length bars ago.

ta.roc(source: number, length: int = 9) → number

Rate of change, in percent.

ta.change(source: number, length: int = 1) → number

The value minus the value length bars ago.

ta.highest(source: number, length: int) → number

The highest value of the last length bars.

let top = ta.highest(high, 20)

ta.lowest(source: number, length: int) → number

The lowest value of the last length bars.

ta.highestBars(source: number, length: int) → int

How many bars ago the highest value of the window was (0 = this bar).

ta.lowestBars(source: number, length: int) → int

How many bars ago the lowest value of the window was.

ta.stdev(source: number, length: int) → number

Standard deviation of the last length values.

ta.variance(source: number, length: int) → number

Variance of the last length values.

ta.median(source: number, length: int) → number

Median of the last length values.

ta.correlation(a: number, b: number, length: int) → number

Correlation of two values over the last length bars, -1 to 1.

ta.cum(source: number) → number

Running total since the first bar (na values are skipped).

ta.sum(source: number, length: int) → number

Sum of the last length values.

ta.crossover(a: number, b: number) → bool

True on the bar where a goes from at or below b to above it.

if ta.crossover(fast, slow) { alert("Up cross") }

ta.crossunder(a: number, b: number) → bool

True on the bar where a goes from at or above b to below it.

ta.cross(a: number, b: number) → bool

True on the bar where a and b cross, either way.

ta.rising(source: number, length: int = 1) → bool

True when the value rose on each of the last length bars.

ta.falling(source: number, length: int = 1) → bool

True when the value fell on each of the last length bars.

ta.barsSince(condition: bool) → int

Bars since the condition was last true (na before it ever was).

ta.valueWhen(condition: bool, source: number, occurrence: int = 0) → number

The source’s value when the condition was last true (occurrence 1: the time before that…).

ta.pivotHigh(source: number = high, left: int = 5, right: int = 5) → number

A swing high: higher than left bars before and right bars after. Reported right bars later; na otherwise.

let ph = ta.pivotHigh(high, 5, 5)
if not isna(ph) {
  mark("PH", position: "above")
}

ta.pivotLow(source: number = low, left: int = 5, right: int = 5) → number

A swing low, reported right bars later; na otherwise.

ta.psar(start: number = 0.02, increment: number = 0.02, maximum: number = 0.2) → number

Parabolic SAR.

Math

Numbers. na in, na out.

NameKindWhat it is
math.pinumberπ, 3.14159…
Also: Math.PI · M_PI
math.enumbere, 2.71828…
Also: Math.E · M_E
math.infnumberInfinity.
Also: INFINITY · Infinity · Double.POSITIVE_INFINITY · math.inf

math.abs(x: number) → number

Absolute value.

Also: Math.abs · std::abs · math.fabs · fabs (C, C++) · std::fabs · abs (Python, C, C++)

math.sign(x: number) → number

1, -1 or 0.

Also: Math.sign · std::sign · Math.signum

math.floor(x: number) → number

Rounds down.

Also: Math.floor · std::floor · floor (C, C++) · math.floor

math.ceil(x: number) → number

Rounds up.

Also: Math.ceil · std::ceil · ceil (C, C++)

math.trunc(x: number) → number

Drops the decimals.

Also: Math.trunc · Math.trunc · std::trunc

math.sqrt(x: number) → number

Square root.

Also: Math.sqrt · std::sqrt · sqrt (C, C++)

math.cbrt(x: number) → number

Cube root.

Also: Math.cbrt · std::cbrt

math.exp(x: number) → number

e to the power x.

Also: Math.exp · std::exp · exp (C, C++)

math.log(x: number) → number

Natural logarithm.

Also: Math.log · std::log · log (C, C++)

math.log10(x: number) → number

Base-10 logarithm.

Also: Math.log10 · std::log10 · log10 (C, C++)

math.log2(x: number) → number

Base-2 logarithm.

Also: Math.log2 · std::log2

math.sin(x: number) → number

Sine (radians).

Also: Math.sin · std::sin · sin (C, C++)

math.cos(x: number) → number

Cosine (radians).

Also: Math.cos · std::cos · cos (C, C++)

math.tan(x: number) → number

Tangent (radians).

Also: Math.tan · std::tan · tan (C, C++)

math.asin(x: number) → number

Arc sine.

Also: Math.asin · std::asin

math.acos(x: number) → number

Arc cosine.

Also: Math.acos · std::acos

math.atan(x: number) → number

Arc tangent.

Also: Math.atan · std::atan

math.toRadians(x: number) → number

Degrees to radians.

Also: Math.toRadians · math.radians

math.toDegrees(x: number) → number

Radians to degrees.

Also: Math.toDegrees · math.degrees

math.round(x: number, decimals: int = 0) → number

Rounds to the nearest whole number, or to a number of decimals.

Also: Math.round · std::round · round (Python, C, C++)

math.round(3.14159, 2)  // 3.14

math.pow(base: number, exponent: number) → number

base to the power exponent.

Also: Math.pow · std::pow · pow (C, C++)

math.atan2(y: number, x: number) → number

The angle of the point (x, y), in radians.

Also: Math.atan2 · std::atan2 · atan2 (C, C++)

math.hypot(…values: number) → number

Square root of the sum of squares.

Also: Math.hypot · std::hypot

math.min(…values: number) → number

The smallest value (na when one is na). Takes numbers or one list.

Also: Math.min · std::min · min (Python)

math.max(…values: number) → number

The largest value (na when one is na). Takes numbers or one list.

Also: Math.max · std::max · max (Python)

math.avg(…values: number) → number

The average of the values. Takes numbers or one list.

math.sum(…values: number) → number

The sum of the values. Takes numbers or one list.

Also: sum (Python)

math.clamp(x: number, lo: number, hi: number) → number

x kept between lo and hi.

Text

Working with text. Texts also have methods.

str.length(s: string) → int

Number of characters.

str.upper(s: string) → string

In capitals.

str.lower(s: string) → string

In small letters.

str.trim(s: string) → string

Without spaces at either end.

str.contains(s: string, part: string) → bool

Whether the text contains the part.

str.startsWith(s: string, part: string) → bool

Whether the text starts with the part.

str.endsWith(s: string, part: string) → bool

Whether the text ends with the part.

str.indexOf(s: string, part: string) → int

Where the part starts in the text (-1 when it is not there).

str.replace(s: string, find: string, with: string) → string

Every occurrence of find replaced.

str.substring(s: string, from: int, to?: int) → string

Part of the text, from a position up to (not including) another.

str.split(s: string, separator: string) → list

The parts of a text between separators, as a list.

str.repeat(s: string, times: int) → string

The text repeated.

str.format(value: number, decimals: int = 2) → string

A number with a fixed number of decimals and thousands separators: 12,345.68

str.toNumber(s: string) → number

The text read as a number (na when it is not one).

str.fromNumber(value: number, decimals?: int) → string

A number as text.

Lists

Making and reading lists. Lists also have methods: push, pop, sort …

array.new(size: int = 0, fill: any = na) → list

A new list of size items, all set to fill.

state closes = array.new()

array.from(…items: any) → list

A list of the given values.

array.sum(list: list) → number

Sum of the list’s numbers.

array.avg(list: list) → number

Average of the list’s numbers.

array.min(list: list) → number

Smallest number in the list.

array.max(list: list) → number

Largest number in the list.

array.stdev(list: list) → number

Standard deviation of the list’s numbers.

array.sort(list: list, descending: bool = false) → list

A sorted copy of the list.

array.reverse(list: list) → list

A reversed copy of the list.

array.slice(list: list, from: int, to?: int) → list

Part of the list, from an index up to (not including) another.

array.indexOf(list: list, value: any) → int

Where the value is in the list (-1 when it is not).

array.includes(list: list, value: any) → bool

Whether the list holds the value.

array.join(list: list, separator: string = ", ") → string

The list’s items as one text.

Colours

A colour is written #rrggbb, #rrggbbaa (with opacity) or by name. In JavaScript, Python, C, C++ and Java, write the hex in quotes: "#2962ff".

  • color.red#f23645
  • color.green#089981
  • color.blue#2962ff
  • color.orange#ff9800
  • color.yellow#ffeb3b
  • color.purple#9c27b0
  • color.teal#009688
  • color.aqua#00bcd4
  • color.lime#00e676
  • color.pink#e91e63
  • color.fuchsia#e040fb
  • color.maroon#880e4f
  • color.navy#311b92
  • color.olive#808000
  • color.white#ffffff
  • color.black#000000
  • color.gray#787b86
  • color.silver#b2b5be
  • color.up#089981 · AlphaChart’s rising colour
  • color.down#f23645 · AlphaChart’s falling colour

color.rgb(r: int, g: int, b: int, alpha: number = 1) → color

A colour from red, green and blue (0 to 255) and an opacity (0 to 1).

color.rgb(255, 109, 0)

color.alpha(color: color, opacity: number) → color

The colour see-through: opacity 0 is invisible, 1 solid.

bgcolor(color.alpha(color.green, 0.15))

color.mix(a: color, b: color, t: number = 0.5) → color

A colour between a and b (t 0 is a, 1 is b).

color.gradient(value: number, low: number, high: number, lowColor: color, highColor: color) → color

A colour between two, by where value sits between low and high.

plot(r, color: color.gradient(r, 30, 70, color.red, color.green))

color.contrast(background: color) → color

Black or white, whichever reads better on the background.

Conversions and na

Turning one kind of value into another, and handling missing values.

isna(value: any) → bool

True when the value is na (missing).

Also: isnan · isNaN · Number.isNaN · Double.isNaN · Float.isNaN · math.isnan · std::isnan

let ok = not isna(close[50])

nz(value: any, replacement: any = 0) → any

The value, or the replacement when it is na. (value ?? replacement does the same.)

Also: fixna

str(value: any, decimals?: int) → string

Any value as text; with decimals, a number rounded to that many places.

Also: String (JavaScript) · String.valueOf · std::to_string · toString · Integer.toString · Double.toString

label("RSI " + str(r, 1), close)

int(value: any) → int

A whole number, cutting off the decimals (text is read as a number).

Also: parseInt · Integer.parseInt · std::stoi · atoi

float(value: any) → number

A number (text is read as a number).

Also: Number (JavaScript) · parseFloat · Double.parseDouble · std::stod · atof · double (C++, C)

bool(value: any) → bool

True or false: 0, na and empty text are false.

Also: Boolean (JavaScript)

len(value: any) → int

How many items a list has, or characters a text.

Methods

Called on a value with a dot: xs.push(close), name.upper(), myLabel.setText("…"). Each language’s usual names work too: push, append, add and push_back all add to a list. Methods without parameters can also be read without brackets: xs.length.

Lists

Indexes start at 0; get(-1) is the last item. Changing methods (push, sort …) change the list itself.

MethodAlsoWhat it does
.push(…values: any)append add pushBack push_back addLastAdds values at the end.
.pop() → anypopBack pop_back removeLastRemoves and gives back the last item.
.shift() → anypopFront pop_front removeFirst popleftRemoves and gives back the first item.
.unshift(…values: any)pushFront push_front addFirst appendleftAdds values at the start.
.insert(index: int, value: any)Puts a value at an index, moving the rest along.
.remove(index: int) → anyremoveAt erase deleteRemoves the item at an index and gives it back.
.get(index: int) → anyat elementAtThe item at an index (-1 is the last).
.set(index: int, value: any)Replaces the item at an index.
.size() → intlength len countHow many items the list has.
.isEmpty() → boolemptyWhether the list has no items.
.clear()Removes every item.
.first() → anyfront getFirstThe first item (na when empty).
.last() → anyback getLast peekThe last item (na when empty).
.sum() → numberSum of the numbers.
.avg() → numbermean averageAverage of the numbers.
.min() → numberSmallest number.
.max() → numberLargest number.
.stdev() → numberStandard deviation of the numbers.
.sort(descending: bool = false)Sorts the list in place (numbers from small to large).
.reverse()Reverses the list in place.
.slice(from: int, to?: int) → listsubList sublistA copy of part of the list.
.copy() → listcloneA copy of the list.
.indexOf(value: any) → intindex findWhere a value is (-1 when it is not there).
.includes(value: any) → boolcontains hasWhether the list holds a value.
.join(separator: string = ",") → stringThe items as one text.
.fill(value: any)Sets every item to the value.
.begin() → intcbeginThe first item’s index, 0 (C++: v.erase(v.begin() + i)).
.end() → intcendThe index after the last item: the size (C++: v.insert(v.end(), x)).

Text

Texts never change: methods give back a new text.

MethodAlsoWhat it does
.length() → intsize lenNumber of characters.
.upper() → stringtoUpperCase toUpperIn capitals.
.lower() → stringtoLowerCase toLowerIn small letters.
.trim() → stringstripWithout spaces at either end.
.contains(part: string) → boolincludesWhether the text contains the part.
.startsWith(part: string) → boolstartswithWhether the text starts with the part.
.endsWith(part: string) → boolendswithWhether the text ends with the part.
.indexOf(part: string) → intfindWhere the part starts (-1 when it is not there).
.replace(find: string, with: string) → stringreplaceAllEvery occurrence replaced.
.substring(from: int, to?: int) → stringsubstr slicePart of the text.
.split(separator: string) → listThe parts between separators.
.charAt(index: int) → stringThe character at a position.
.repeat(times: int) → stringThe text repeated.
.isEmpty() → boolemptyWhether the text is empty.
.equals(other: string) → boolWhether two texts are the same.
.format(…values: any) → stringThe text with each {} filled in, as Python writes it: "{:.2f}".format(x).

Numbers

For JavaScript and Java habits. On na they give "na".

MethodAlsoWhat it does
.toFixed(decimals: int = 0) → stringThe number as text with a fixed number of decimals.
.toPrecision(digits: int) → stringThe number as text with a number of significant digits.
.toString() → stringThe number as text.

Labels

The handle label() gives back.

MethodAlsoWhat it does
.setText(text: string)Changes the text.
.setPrice(price: number)setYMoves it to a price.
.setBar(bar: int)setX setAtMoves it to a bar.
.move(bar: int, price: number)setXYMoves it to a bar and a price.
.setColor(color: color)Changes the bubble’s colour.
.setTextColor(color: color)Changes the text’s colour.
.setStyle(style: string)up, down, left, right, center or none.
.setSize(size: string)tiny, small, normal or large.
.remove()deleteRemoves it from the chart.
.text() → stringgetTextIts text.
.price() → numbergetPrice getYIts price.
.bar() → intgetBar getXIts bar.

Lines

The handle line() gives back.

MethodAlsoWhat it does
.setX1(bar: int)Moves the start to a bar.
.setY1(price: number)Moves the start to a price.
.setX2(bar: int)Moves the end to a bar.
.setY2(price: number)Moves the end to a price.
.setXY1(bar: int, price: number)setStartMoves the start.
.setXY2(bar: int, price: number)setEndMoves the end.
.setColor(color: color)Changes the colour.
.setWidth(width: int)Changes the width (1 to 10).
.setStyle(style: string)solid, dashed or dotted.
.setExtend(extend: string)none, left, right or both.
.remove()deleteRemoves it from the chart.
.priceAt(bar: int) → numbergetPrice valueAtThe line’s price at a bar (it may lie beyond its ends).
.x1() → intThe start’s bar.
.y1() → numberThe start’s price.
.x2() → intThe end’s bar.
.y2() → numberThe end’s price.

Boxes

The handle box() gives back.

MethodAlsoWhat it does
.setLeft(bar: int)Moves the left edge to a bar.
.setRight(bar: int)Moves the right edge to a bar.
.setTop(price: number)Moves the top to a price.
.setBottom(price: number)Moves the bottom to a price.
.setText(text: string)Changes the text inside.
.setColor(color: color)setBorderColorChanges the border’s colour.
.setFill(color: color)setBgColor setBackgroundChanges the inside’s colour.
.setExtend(extend: bool)Whether it carries on to the right edge.
.remove()deleteRemoves it from the chart.
.top() → numberThe top’s price.
.bottom() → numberThe bottom’s price.
.left() → intThe left edge’s bar.
.right() → intThe right edge’s bar.