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.
Nothing matches.
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.
| Name | Kind | What it is |
|---|---|---|
open | number | The bar’s opening price. |
high | number | The bar’s highest price. |
low | number | The bar’s lowest price. |
close | number | The bar’s closing price (the last price while the bar is open). |
volume | number | The bar’s volume. |
hl2 | number | (high + low) / 2 |
hlc3 | number | (high + low + close) / 3 |
ohlc4 | number | (open + high + low + close) / 4 |
hlcc4 | number | (high + low + 2 × close) / 4 |
time | number | The bar’s opening time, in milliseconds since 1970 (UTC). |
buyVolume | number | Volume bought at the ask (taker buys), where the exchange reports it; na elsewhere. |
sellVolume | number | Volume sold at the bid (taker sells), where the exchange reports it; na elsewhere. |
delta | number | Buy volume minus sell volume (order flow delta), where the exchange reports it. |
barIndex | number | The bar’s number: 0 for the oldest loaded bar. |
barCount | int | How many bars are loaded. |
isFirstBar | bool | True on the oldest loaded bar. |
isLastBar | bool | True on the newest bar. |
Symbol
What the chart is showing.
| Name | Kind | What it is |
|---|---|---|
symbol.name | string | The symbol as the chart shows it: BTCUSDT, AAPL, EURUSD. |
symbol.ticker | string | The exchange’s own code for the symbol. |
symbol.exchange | string | The exchange or data source: BINANCE, NASDAQ, BIST … |
symbol.type | string | crypto, stock, forex, index, futures, commodity … |
symbol.currency | string | The currency prices are in. |
symbol.tickSize | number | The smallest price step. |
Time and interval
When a bar is, in the chart’s time zone, and how long one bar lasts.
| Name | Kind | What it is |
|---|---|---|
timeframe.seconds | int | Seconds in one bar (a day is 86400). |
timeframe.minutes | number | Minutes in one bar. |
timeframe.text | string | The interval as the chart writes it: 1m, 15m, 1h, 1D … |
timeframe.isIntraday | bool | Bars shorter than a day. |
timeframe.isDaily | bool | Daily bars. |
timeframe.isWeekly | bool | Weekly bars. |
timeframe.isMonthly | bool | Monthly 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.
| Name | Kind | What it is |
|---|---|---|
math.pi | number | π, 3.14159… Also: Math.PI · M_PI |
math.e | number | e, 2.71828… Also: Math.E · M_E |
math.inf | number | Infinity. 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.14math.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#f23645color.green#089981color.blue#2962ffcolor.orange#ff9800color.yellow#ffeb3bcolor.purple#9c27b0color.teal#009688color.aqua#00bcd4color.lime#00e676color.pink#e91e63color.fuchsia#e040fbcolor.maroon#880e4fcolor.olive#808000color.white#ffffffcolor.black#000000color.gray#787b86color.silver#b2b5becolor.up#089981 · AlphaChart’s rising colourcolor.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.
| Method | Also | What it does |
|---|---|---|
.push(…values: any) | append add pushBack push_back addLast | Adds values at the end. |
.pop() → any | popBack pop_back removeLast | Removes and gives back the last item. |
.shift() → any | popFront pop_front removeFirst popleft | Removes and gives back the first item. |
.unshift(…values: any) | pushFront push_front addFirst appendleft | Adds values at the start. |
.insert(index: int, value: any) | Puts a value at an index, moving the rest along. | |
.remove(index: int) → any | removeAt erase delete | Removes the item at an index and gives it back. |
.get(index: int) → any | at elementAt | The item at an index (-1 is the last). |
.set(index: int, value: any) | Replaces the item at an index. | |
.size() → int | length len count | How many items the list has. |
.isEmpty() → bool | empty | Whether the list has no items. |
.clear() | Removes every item. | |
.first() → any | front getFirst | The first item (na when empty). |
.last() → any | back getLast peek | The last item (na when empty). |
.sum() → number | Sum of the numbers. | |
.avg() → number | mean average | Average of the numbers. |
.min() → number | Smallest number. | |
.max() → number | Largest number. | |
.stdev() → number | Standard 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) → list | subList sublist | A copy of part of the list. |
.copy() → list | clone | A copy of the list. |
.indexOf(value: any) → int | index find | Where a value is (-1 when it is not there). |
.includes(value: any) → bool | contains has | Whether the list holds a value. |
.join(separator: string = ",") → string | The items as one text. | |
.fill(value: any) | Sets every item to the value. | |
.begin() → int | cbegin | The first item’s index, 0 (C++: v.erase(v.begin() + i)). |
.end() → int | cend | The index after the last item: the size (C++: v.insert(v.end(), x)). |
Text
Texts never change: methods give back a new text.
| Method | Also | What it does |
|---|---|---|
.length() → int | size len | Number of characters. |
.upper() → string | toUpperCase toUpper | In capitals. |
.lower() → string | toLowerCase toLower | In small letters. |
.trim() → string | strip | Without spaces at either end. |
.contains(part: string) → bool | includes | Whether the text contains the part. |
.startsWith(part: string) → bool | startswith | Whether the text starts with the part. |
.endsWith(part: string) → bool | endswith | Whether the text ends with the part. |
.indexOf(part: string) → int | find | Where the part starts (-1 when it is not there). |
.replace(find: string, with: string) → string | replaceAll | Every occurrence replaced. |
.substring(from: int, to?: int) → string | substr slice | Part of the text. |
.split(separator: string) → list | The parts between separators. | |
.charAt(index: int) → string | The character at a position. | |
.repeat(times: int) → string | The text repeated. | |
.isEmpty() → bool | empty | Whether the text is empty. |
.equals(other: string) → bool | Whether two texts are the same. | |
.format(…values: any) → string | The text with each {} filled in, as Python writes it: "{:.2f}".format(x). |
Numbers
For JavaScript and Java habits. On na they give "na".
| Method | Also | What it does |
|---|---|---|
.toFixed(decimals: int = 0) → string | The number as text with a fixed number of decimals. | |
.toPrecision(digits: int) → string | The number as text with a number of significant digits. | |
.toString() → string | The number as text. |
Labels
The handle label() gives back.
| Method | Also | What it does |
|---|---|---|
.setText(text: string) | Changes the text. | |
.setPrice(price: number) | setY | Moves it to a price. |
.setBar(bar: int) | setX setAt | Moves it to a bar. |
.move(bar: int, price: number) | setXY | Moves 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() | delete | Removes it from the chart. |
.text() → string | getText | Its text. |
.price() → number | getPrice getY | Its price. |
.bar() → int | getBar getX | Its bar. |
Lines
The handle line() gives back.
| Method | Also | What 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) | setStart | Moves the start. |
.setXY2(bar: int, price: number) | setEnd | Moves 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() | delete | Removes it from the chart. |
.priceAt(bar: int) → number | getPrice valueAt | The line’s price at a bar (it may lie beyond its ends). |
.x1() → int | The start’s bar. | |
.y1() → number | The start’s price. | |
.x2() → int | The end’s bar. | |
.y2() → number | The end’s price. |
Boxes
The handle box() gives back.
| Method | Also | What 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) | setBorderColor | Changes the border’s colour. |
.setFill(color: color) | setBgColor setBackground | Changes the inside’s colour. |
.setExtend(extend: bool) | Whether it carries on to the right edge. | |
.remove() | delete | Removes it from the chart. |
.top() → number | The top’s price. | |
.bottom() → number | The bottom’s price. | |
.left() → int | The left edge’s bar. | |
.right() → int | The right edge’s bar. |