millionchart
فارسی

Function index

Every built-in function and variable of the language, by group, with the parameters in order; written from the engine itself.

This page lists the 415 built-in functions and 150 built-in variables the engine knows. It is generated from the engine, so it always matches the version you are running.

Functions#

General#

  • bool([value])
  • confirmed(value)
  • current(period).field
  • falls(condition)
  • float([value])
  • int([value])
  • is_na([value])
  • level(price, [name], [color], [style], [width], [display], [key], [was])
  • plot(source, [name], [color], [width], [style], [track_price], [base], [offset], [join], [last_bars], [display], [format], [precision], [key], [was])
  • plot_bars([open], [high], [low], [close], [name], [color], [last_bars], [display], [format], [precision], [key], [was])
  • plot_candles([open], [high], [low], [close], [name], [color], [wick_color], [last_bars], [border_color], [display], [format], [precision], [key], [was])
  • prior(period [, n]).field
  • rises(condition)
  • shade(a, b, [color], [name], [last_bars], [fill_gaps], [display], [max], [min], [max_color], [min_color], [key], [was])

NAME#

  • NAME.active
  • NAME.end
  • NAME.high
  • NAME.index
  • NAME.low
  • NAME.start

alert#

  • alert.send([message], [key], [once], [cooldown])
  • alert.when([condition], [name], [message], [on], [key], [was])

array#

  • array.abs([array])
  • array.all([array])
  • array.any([array])
  • array.at(array, index)
  • array.avg([array])
  • array.binary_search([array], [value])
  • array.binary_search_leftmost([array], [value])
  • array.binary_search_rightmost([array], [value])
  • array.clear(array)
  • array.concat([array], [other])
  • array.contains([array], [value])
  • array.copy([array])
  • array.covariance([array], [other], [biased])
  • array.fill([array], [value], [from], [to])
  • array.first([array])
  • array.index_of([array], [value])
  • array.insert([array], [index], [value])
  • array.join([array], [separator])
  • array.last([array])
  • array.last_index_of([array], [value])
  • array.max([array], [nth])
  • array.median([array])
  • array.min([array], [nth])
  • array.mode([array])
  • array.new([size], [initial])
  • array.percent_rank([array], [index])
  • array.percentile([array], [percent])
  • array.percentile_nearest([array], [percent])
  • array.pop(array)
  • array.push(array, value)
  • array.range([array])
  • array.remove(array, index)
  • array.reverse([array])
  • array.set(array, index, value)
  • array.shift([array])
  • array.size(array)
  • array.slice([array], [from], [to])
  • array.sort([array], [order])
  • array.sort_indices([array], [order])
  • array.standardize([array])
  • array.stdev([array], [biased])
  • array.sum([array])
  • array.unshift([array], [value])
  • array.variance([array], [biased])

bar#

  • bar.close_time_in([tf], [session], [zone], [offset])
  • bar.time_in([tf], [session], [zone], [offset])

box#

  • box.copy([box])
  • box.delete([box])
  • box.get_bottom([box])
  • box.get_left([box])
  • box.get_right([box])
  • box.get_top([box])
  • box.new(left, top, [right], [bottom], [border_color], [border_width], [border_style], [extend], [x_unit], [background], [text], [text_size], [text_color], [h_align], [v_align], [top_left], [bottom_right])
  • box.set_background([box], [color])
  • box.set_border_color([box], [color])
  • box.set_border_style([box], [style])
  • box.set_border_width([box], [width])
  • box.set_bottom([box], [bottom])
  • box.set_bottom_right([box], [right], [bottom])
  • box.set_bottom_right_point([box], [point])
  • box.set_extend([box], [extend])
  • box.set_h_align([box], [h_align])
  • box.set_left([box], [left])
  • box.set_right([box], [right])
  • box.set_text([box], [text])
  • box.set_text_color([box], [text_color])
  • box.set_text_size([box], [text_size])
  • box.set_top([box], [top])
  • box.set_top_left([box], [left], [top])
  • box.set_top_left_point([box], [point])
  • box.set_v_align([box], [v_align])
  • box.set_x_unit([box], [left], [right], [x_unit])

chart#

  • chart.background([color], [offset], [last_bars], [name], [display], [key], [was])
  • chart.candles([color], [offset], [last_bars], [name], [display], [body], [wick], [border])
  • chart.point.at_index([index], [price])
  • chart.point.at_time([time], [price])
  • chart.point.copy([point])
  • chart.point.new([time], [index], [price])
  • chart.point.now([price])

clock#

  • clock.day_of([time], [zone])
  • clock.hour_of([time], [zone])
  • clock.minute_of([time], [zone])
  • clock.month_of([time], [zone])
  • clock.reached([time], [zone])
  • clock.second_of([time], [zone])
  • clock.timestamp([year], [month], [day], [hour], [minute], [second], [zone])
  • clock.week_of([time], [zone])
  • clock.weekday_of([time], [zone])
  • clock.year_of([time], [zone])

color#

  • color.blue_of([color])
  • color.fade(color, [percent])
  • color.fade_of([color])
  • color.gradient([value], [min], [max], [min_color], [max_color])
  • color.green_of([color])
  • color.red_of([color])
  • color.rgb(red, green, blue, [fade])

data#

  • data.intrabars([tf], [expression], [symbol], [allow_missing])
  • data.series(tf, expression, symbol, [gaps], [future], [allow_missing], [live])

label#

  • label.copy([label])
  • label.delete([label])
  • label.get_text([label])
  • label.get_x([label])
  • label.get_y([label])
  • label.new(x, [y], [text], [x_unit], [place], [color], [style], [text_color], [text_size], [text_align], [tooltip], [point])
  • label.set_color([label], [color])
  • label.set_place([label], [place])
  • label.set_point([label], [point])
  • label.set_style([label], [style])
  • label.set_text([label], [text])
  • label.set_text_align([label], [text_align])
  • label.set_text_color([label], [text_color])
  • label.set_text_size([label], [size])
  • label.set_tooltip([label], [tooltip])
  • label.set_x([label], [x])
  • label.set_x_unit([label], [x], [x_unit])
  • label.set_xy([label], [x], [y])
  • label.set_y([label], [y])

line#

  • line.copy([line])
  • line.delete([line])
  • line.get_price([line], [x])
  • line.get_x1([line])
  • line.get_x2([line])
  • line.get_y1([line])
  • line.get_y2([line])
  • line.new(x1, y1, [x2], [y2], [x_unit], [extend], [color], [style], [width], [first_point], [second_point])
  • line.set_color([line], [color])
  • line.set_extend([line], [extend])
  • line.set_first_point([line], [point])
  • line.set_second_point([line], [point])
  • line.set_style([line], [style])
  • line.set_width([line], [width])
  • line.set_x1([line], [x])
  • line.set_x2([line], [x])
  • line.set_x_unit([line], [x1], [x2], [x_unit])
  • line.set_xy1([line], [x], [y])
  • line.set_xy2([line], [x], [y])
  • line.set_y1([line], [y])
  • line.set_y2([line], [y])

log#

  • log.abort([message])
  • log.error([message], ...values)
  • log.info([message], ...values)
  • log.warning([message], ...values)

map#

  • map.at([map], [key])
  • map.clear([map])
  • map.contains([map], [key])
  • map.copy([map])
  • map.keys([map])
  • map.new()
  • map.remove([map], [key])
  • map.set([map], [key], [value])
  • map.set_all([map], [other])
  • map.size([map])
  • map.values([map])

mark#

  • mark.arrow([source], [name], [up_color], [down_color], [offset], [min_height], [max_height], [last_bars], [display], [format], [precision], [key], [was])
  • mark.char([condition], [name], [char], [place], [color], [offset], [text], [text_color], [size], [last_bars], [display], [format], [precision], [key], [was])
  • mark.shape([condition], [name], [shape], [place], [color], [offset], [text], [text_color], [size], [last_bars], [display], [format], [precision], [key], [was])

math#

  • math.abs(value)
  • math.acos([value])
  • math.asin([value])
  • math.atan([value])
  • math.avg(...values)
  • math.ceil(value)
  • math.cos(value)
  • math.exp(value)
  • math.floor(value)
  • math.log(value)
  • math.log10(value)
  • math.max(...values)
  • math.min(...values)
  • math.pow(base, exponent)
  • math.random([min], [max], [seed])
  • math.rem(a, b)
  • math.round(value, [precision])
  • math.sign(value)
  • math.sin(value)
  • math.sqrt(value)
  • math.tan(value)
  • math.to_degrees([value])
  • math.to_radians([value])

matrix#

  • matrix.add([matrix], [other])
  • matrix.add_column([matrix], [column], [array_id])
  • matrix.add_row([matrix], [row], [array_id])
  • matrix.at([matrix], [row], [column])
  • matrix.avg([matrix])
  • matrix.column([matrix], [column])
  • matrix.columns([matrix])
  • matrix.concat([matrix], [other])
  • matrix.copy([matrix])
  • matrix.count([matrix])
  • matrix.det([matrix])
  • matrix.eigenvalues([matrix])
  • matrix.eigenvectors([matrix])
  • matrix.fill([matrix], [value], [from_row], [to_row], [from_column], [to_column])
  • matrix.inv([matrix])
  • matrix.is_antidiagonal([matrix])
  • matrix.is_antisymmetric([matrix])
  • matrix.is_binary([matrix])
  • matrix.is_diagonal([matrix])
  • matrix.is_identity([matrix])
  • matrix.is_square([matrix])
  • matrix.is_stochastic([matrix])
  • matrix.is_symmetric([matrix])
  • matrix.is_triangular([matrix])
  • matrix.is_zero([matrix])
  • matrix.kron([matrix], [other])
  • matrix.max([matrix])
  • matrix.median([matrix])
  • matrix.min([matrix])
  • matrix.mode([matrix])
  • matrix.multiply([matrix], [other])
  • matrix.new([rows], [columns], [initial])
  • matrix.pinv([matrix])
  • matrix.pow([matrix], [exponent])
  • matrix.rank([matrix])
  • matrix.remove_column([matrix], [column])
  • matrix.remove_row([matrix], [row])
  • matrix.reshape([matrix], [rows], [columns])
  • matrix.reverse([matrix])
  • matrix.row([matrix], [row])
  • matrix.rows([matrix])
  • matrix.set([matrix], [row], [column], [value])
  • matrix.slice([matrix], [from_row], [to_row], [from_column], [to_column])
  • matrix.sort([matrix], [column], [order])
  • matrix.subtract([matrix], [other])
  • matrix.swap_columns([matrix], [column1], [column2])
  • matrix.swap_rows([matrix], [row1], [row2])
  • matrix.trace([matrix])
  • matrix.transpose([matrix])

orders#

  • orders.cancel([key])
  • orders.cancel_all()
  • orders.close(key, [comment], [qty], [qty_percent], [message], [immediately], [silent])
  • orders.close_all([comment], [message], [immediately], [silent])
  • orders.enter(key, side, [qty], [limit], [stop], [oca], [oca_type], [comment], [message], [silent], [expires])
  • orders.exit(key, [entry], [qty], [qty_percent], [profit_ticks], [limit], [loss_ticks], [stop], [trail_price], [trail_ticks], [trail_offset_ticks], [oca], [comment], [profit_comment], [loss_comment], [trail_comment], [message], [profit_message], [loss_message], [trail_message], [silent])
  • orders.place(key, side, [qty], [limit], [stop], [oca], [oca_type], [comment], [message], [silent], [expires])

polyline#

  • polyline.delete([polyline])
  • polyline.new([points], [curved], [closed], [x_unit], [color], [style], [width])

risk#

  • risk.allow_entries([value], [unit], [message])
  • risk.max_daily_loss([value], [unit], [message])
  • risk.max_daily_orders([value], [unit], [message])
  • risk.max_drawdown([value], [unit], [message])
  • risk.max_losing_days([value], [unit], [message])
  • risk.max_position([value], [unit], [message])

sizing#

  • sizing.default_qty([price])
  • sizing.to_account([value])
  • sizing.to_symbol([value])

symbol#

  • symbol.price_of([ticks])
  • symbol.snap([price])
  • symbol.snap_down([price])
  • symbol.snap_up([price])
  • symbol.ticks([price])
  • symbol.ticks_down([price])
  • symbol.ticks_up([price])

table#

  • table.cell(table, column, row, [text], [width], [height], [text_color], [h_align], [v_align], [text_size], [background])
  • table.clear([table], [from_column], [from_row], [to_column], [to_row])
  • table.delete([table])
  • table.merge_cells([table], [from_column], [from_row], [to_column], [to_row])
  • table.new(position, columns, rows, [background], [frame_color], [frame_width], [border_color], [border_width])
  • table.set_background([table], [background])
  • table.set_border_color([table], [border_color])
  • table.set_border_width([table], [border_width])
  • table.set_cell_background([table], [column], [row], [background])
  • table.set_cell_h_align([table], [column], [row], [h_align])
  • table.set_cell_height([table], [column], [row], [height])
  • table.set_cell_text([table], [column], [row], [text])
  • table.set_cell_text_color([table], [column], [row], [text_color])
  • table.set_cell_text_size([table], [column], [row], [text_size])
  • table.set_cell_v_align([table], [column], [row], [v_align])
  • table.set_cell_width([table], [column], [row], [width])
  • table.set_frame_color([table], [frame_color])
  • table.set_frame_width([table], [frame_width])
  • table.set_position([table], [position])

tech#

  • tech.alma([source], [length], [bias], [sigma], [floor])
  • tech.atr(length)
  • tech.avg_dev([source], [length])
  • tech.bars_since(condition)
  • tech.bb(source, length, mult)
  • tech.bbw(source, length, mult)
  • tech.carry([source])
  • tech.cci(source, length)
  • tech.change(source, [length])
  • tech.cmo(source, length)
  • tech.cog([source], [length])
  • tech.correlation(source, other, length)
  • tech.crosses(source, other)
  • tech.crosses_above(source, other)
  • tech.crosses_below(source, other)
  • tech.cum_sum(source)
  • tech.dmi([di_length], [adx_length])
  • tech.ema(source, length)
  • tech.highest(source, [length])
  • tech.highest_offset(source, [length])
  • tech.hma(source, length)
  • tech.is_falling(source, length)
  • tech.is_rising(source, length)
  • tech.kc(source, length, mult, [use_true_range])
  • tech.kcw([source], [length], [mult], [use_true_range])
  • tech.linreg([source], [length], [offset])
  • tech.lowest(source, [length])
  • tech.lowest_offset(source, [length])
  • tech.macd(source, fast_length, slow_length, signal_length)
  • tech.median([source], [length])
  • tech.mfi(source, length)
  • tech.mode([source], [length])
  • tech.mom(source, length)
  • tech.percent_rank(source, length)
  • tech.percentile([source], [length], [percent])
  • tech.percentile_nearest([source], [length], [percent])
  • tech.pivot_high(source, left_bars, [right_bars])
  • tech.pivot_levels([kind], [anchor], [developing])
  • tech.pivot_low(source, left_bars, [right_bars])
  • tech.range([source], [length])
  • tech.rci([source], [length])
  • tech.rma(source, length)
  • tech.roc(source, length)
  • tech.rsi(source, length)
  • tech.running_max([source])
  • tech.running_min([source])
  • tech.sample_when(source, condition, occurrence)
  • tech.sar([start], [step], [max])
  • tech.sma(source, length)
  • tech.stdev(source, length, [biased])
  • tech.stoch(source, length, high, low)
  • tech.sum(source, length)
  • tech.supertrend([factor], [atr_length])
  • tech.swma([source])
  • tech.tr([handle_na])
  • tech.tsi([source], [short_length], [long_length])
  • tech.variance(source, length, [biased])
  • tech.vwap([source], [anchor], [mult])
  • tech.vwma(source, length)
  • tech.wma(source, length)
  • tech.wpr([length])

text#

  • text.contains(text, part)
  • text.ends_with(text, part)
  • text.fmt([value], [spec], [fallback], [zone])
  • text.format([pattern], ...values)
  • text.format_time([time], [pattern], [zone])
  • text.index_of(text, part)
  • text.length(text)
  • text.lower(text)
  • text.match([text], [pattern])
  • text.of(value, [format])
  • text.repeat(text, count, [separator])
  • text.replace(text, target, replacement, [occurrence])
  • text.replace_all(text, target, replacement)
  • text.slice(text, from, [to])
  • text.split(text, separator)
  • text.starts_with(text, part)
  • text.to_number(text)
  • text.trim(text)
  • text.upper(text)

tf#

  • tf.changed([tf])
  • tf.from_seconds([seconds])
  • tf.to_seconds([tf])

trades#

  • trades.closed.capital_held()
  • trades.closed.entry_comment([index])
  • trades.closed.entry_index([index])
  • trades.closed.entry_key([index])
  • trades.closed.entry_price([index])
  • trades.closed.entry_time([index])
  • trades.closed.exit_comment([index])
  • trades.closed.exit_index([index])
  • trades.closed.exit_key([index])
  • trades.closed.exit_price([index])
  • trades.closed.exit_time([index])
  • trades.closed.fees([index])
  • trades.closed.max_drawdown([index])
  • trades.closed.max_drawdown_percent([index])
  • trades.closed.max_runup([index])
  • trades.closed.max_runup_percent([index])
  • trades.closed.profit([index])
  • trades.closed.profit_percent([index])
  • trades.closed.size([index])
  • trades.open.capital_held()
  • trades.open.entry_comment([index])
  • trades.open.entry_index([index])
  • trades.open.entry_key([index])
  • trades.open.entry_price([index])
  • trades.open.entry_time([index])
  • trades.open.exit_comment([index])
  • trades.open.exit_index([index])
  • trades.open.exit_key([index])
  • trades.open.exit_price([index])
  • trades.open.exit_time([index])
  • trades.open.fees([index])
  • trades.open.max_drawdown([index])
  • trades.open.max_drawdown_percent([index])
  • trades.open.max_runup([index])
  • trades.open.max_runup_percent([index])
  • trades.open.profit([index])
  • trades.open.profit_percent([index])
  • trades.open.size([index])

Variables and constants#

  • General: close, high, hl2, hlc3, hlcc4, low, ohlc4, open, trading_day, volume
  • bar: bar.close_time, bar.index, bar.is_closed, bar.is_first, bar.is_first_of_day, bar.is_history, bar.is_last, bar.is_last_history, bar.is_last_of_day, bar.is_live, bar.last_index, bar.last_time, bar.time
  • box: box.all
  • chart: chart.theme_background, chart.theme_foreground
  • clock: clock.day, clock.friday, clock.hour, clock.minute, clock.monday, clock.month, clock.now, clock.saturday, clock.second, clock.sunday, clock.thursday, clock.tuesday, clock.wednesday, clock.week, clock.weekday, clock.year
  • color: color.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
  • label: label.all
  • line: line.all
  • math: math.e, math.phi, math.pi
  • polyline: polyline.all
  • position: position.avg_price, position.entry_key, position.liquidation_price, position.size
  • side: side.both, side.long, side.short
  • stats: stats.account_currency, stats.avg_loss, stats.avg_loss_percent, stats.avg_trade, stats.avg_trade_percent, stats.avg_win, stats.avg_win_percent, stats.capital, stats.day_low_equity, stats.day_start_equity, stats.equity, stats.equity_low, stats.gross_loss, stats.gross_loss_percent, stats.gross_profit, stats.gross_profit_percent, stats.max_drawdown, stats.max_drawdown_percent, stats.max_runup, stats.max_runup_percent, stats.max_size, stats.max_size_long, stats.max_size_short, stats.net_profit, stats.net_profit_percent, stats.open_profit, stats.open_profit_percent
  • symbol: symbol.base_currency, symbol.category, symbol.contract_size, symbol.currency, symbol.id, symbol.lot_step, symbol.margin_rate, symbol.max_lot, symbol.min_lot, symbol.name, symbol.pip, symbol.point_value, symbol.price_scale, symbol.spec_date, symbol.spec_source, symbol.swap_long, symbol.swap_mode, symbol.swap_short, symbol.swap_triple_day, symbol.tick, symbol.tick_value, symbol.ticker, symbol.venue, symbol.volume_type, symbol.zone
  • table: table.all
  • tech: tech.accdist, tech.iii, tech.nvi, tech.obv, tech.pvi, tech.pvt, tech.tr, tech.vwap, tech.wad, tech.wvad
  • tf: tf.id, tf.is_daily, tf.is_daily_or_longer, tf.is_intraday, tf.is_minutes, tf.is_monthly, tf.is_seconds, tf.is_weekly, tf.multiplier
  • trades: trades.closed.first_index, trades.closed_count, trades.even_count, trades.lost_count, trades.open_count, trades.won_count

See also: Write your own scripts