Vela, our next-generation charting platform, is live at vela.luxalgo.com.
LuxAlgo

Indicators

API reference for the indicator menu, favorites, indicator templates, and the Pine Script® library resolver.

View as Markdown

This page documents the indicator menu, favorite indicator storage, indicator templates and their storage port, and the resolver interface for import statements in Pine Script®.

Import symbols on this page from @luxalgo/vela-pro. Related guides: Indicator menu, Indicator templates, Pine Script® with PineTS.

Feature enablers for this area (enableIndicatorLibrary, enableIndicatorTemplates, enablePineEngine) are documented on Enablers and options.

Functions

applyTemplate

Apply a template: remove the chart's indicators, switch to the saved market (when the template has one and the target can), then add the template's indicators with their settings. Removals first, so the outgoing set is not recomputed over the new market.

function applyTemplate(
    target: TemplateTarget,
    template: Pick<IndicatorTemplate, 'symbol' | 'timeframe' | 'indicators'>,
): void

See also: IndicatorTemplate, TemplateTarget.

applyTemplateWithScope

Apply a template: on a grid, after asking which charts it goes to.

function applyTemplateWithScope(ctx: WidgetContext, template: IndicatorTemplate): void

See also: IndicatorTemplate. From @luxalgo/vela/plugin: WidgetContext.

captureIndicators

The chart's indicators as template entries (a script by its source, a built-in by its type).

function captureIndicators(chart: Chart): TemplateIndicator[]

// Unexported supporting type referenced above
type Chart = WidgetContext['chart'];

See also: TemplateIndicator. From @luxalgo/vela/plugin: WidgetContext.

chartTarget

Another chart of the grid: its indicators only (its market is its own).

function chartTarget(chart: Chart): TemplateTarget

// Unexported supporting type referenced above
type Chart = WidgetContext['chart'];

See also: TemplateTarget. From @luxalgo/vela/plugin: WidgetContext.

indicatorFavorites

The page's favorite-indicators store: created on first use with the localStorage adapter when the enabler installed none.

function indicatorFavorites(): IndicatorFavoritesStore

See also: IndicatorFavoritesStore.

indicatorTemplatesController

function indicatorTemplatesController(): IndicatorTemplatesController | null

See also: IndicatorTemplatesController.

localIndicatorFavoritesStorage

The zero-wiring default (and the dev-page adapter): favorites under one localStorage key. Quota/privacy failures degrade to session-only silently.

function localIndicatorFavoritesStorage(key?: string): IndicatorFavoritesStorage

Default: key = 'vela-pro-indicator-favorites'.

See also: IndicatorFavoritesStorage.

newTemplateName

The typed name, or New template, New template 2…: whichever is free.

function newTemplateName(typed: string, existing?: readonly string[]): string

openManageTemplatesDialog

Every template: apply, rename, delete, and what each holds.

function openManageTemplatesDialog(ctx: WidgetContext, c: IndicatorTemplatesController): void

See also: IndicatorTemplatesController. From @luxalgo/vela/plugin: WidgetContext.

openSaveTemplateDialog

Save the active chart's indicators as a template.

function openSaveTemplateDialog(ctx: WidgetContext, c: IndicatorTemplatesController): void

See also: IndicatorTemplatesController. From @luxalgo/vela/plugin: WidgetContext.

pineLibraryResolver

An import resolver reading each library from a URL. A 404 means the server does not have that library (the script then fails to prepare, naming the import); any other failed response throws. A library is fetched once per resolver, and a failed fetch is tried again the next time a script imports it.

function pineLibraryResolver(opts: PineLibraryResolverOptions): (path: string, library: PineLibraryImport) => Promise<string | null>

See also: PineLibraryResolverOptions. From @luxalgo/vela-pinets: PineLibraryImport.

shellTarget

The shell's active chart: market switches and adds go through the shell (undo-recorded).

function shellTarget(ctx: WidgetContext): TemplateTarget

See also: TemplateTarget. From @luxalgo/vela/plugin: WidgetContext.

templateMeta

BTC-USD · 1h · 3 indicators.

function templateMeta(t: Pick<IndicatorTemplate, 'symbol' | 'timeframe' | 'indicators'>): string

See also: IndicatorTemplate.

templateWithName

The template a save under name would overwrite: same name, ignoring case and spacing.

function templateWithName<T extends { name: string }>(
    templates: readonly T[],
    name: string,
): T | undefined

Classes

IndicatorFavoritesStore

class IndicatorFavoritesStore {
    constructor(storage: IndicatorFavoritesStorage);
    list(): readonly IndicatorFavorite[];
    has(id: string): boolean;
    toggle(fav: IndicatorFavorite): boolean;
    subscribe(listener: () => void): () => void;
}
MemberTypeDescription
constructor(storage: IndicatorFavoritesStorage)
list()() => readonly IndicatorFavorite[]
has()(id: string) => boolean
toggle()(fav: IndicatorFavorite) => booleanFlip one favorite; returns the NEW state (true = now a favorite).
subscribe()(listener: () => void) => () => void

See also: IndicatorFavorite, IndicatorFavoritesStorage.

IndicatorTemplatesController class

The page's templates: one list every shell's button reads, kept by the storage port.

class IndicatorTemplatesController {
    constructor(storage: IndicatorTemplatesStorage, canCreate?: () => boolean);
    readonly ready: Promise<void>;
    readonly canCreate: () => boolean;
    list(): IndicatorTemplate[];
    onChange(cb: () => void): () => void;
    reload(): Promise<void>;
    save(template: IndicatorTemplate): Promise<void>;
    rename(id: string, name: string): Promise<void>;
    remove(id: string): Promise<void>;
}
MemberTypeDescription
constructor(storage: IndicatorTemplatesStorage, canCreate?: () => boolean)canCreate: Asked before every save; false stops it (a plan's cap: the host shows why). Default: canCreate = () => true.
readyPromise<void>
canCreate() => boolean
list()() => IndicatorTemplate[]
onChange()(cb: () => void) => () => void
reload()() => Promise<void>
save()(template: IndicatorTemplate) => Promise<void>
rename()(id: string, name: string) => Promise<void>
remove()(id: string) => Promise<void>

See also: IndicatorTemplate, IndicatorTemplatesStorage.

LibraryClient

class LibraryClient {
    constructor(opts?: LibraryClientOptions);
    query(q?: LibraryQuery): Promise<LibraryPage>;
    indicatorBySlug(slug: string): Promise<LibraryIndicatorSummary | null>;
    concepts(): Promise<LibraryConcept[]>;
    script(pineScriptCodeId: string): Promise<string>;
    scriptBySlug(slug: string): Promise<{ name: string; code: string }>;
}

// Unexported supporting type referenced above
interface LibraryConcept {
    id: string;
    slug: string;
    name: string;
    family: string;
    cluster: string | null;
    aliases: readonly string[];
    isFringe?: boolean;
}
MemberTypeDescription
constructor(opts?: LibraryClientOptions)
query()(q?: LibraryQuery) => Promise<LibraryPage>Filtered/paginated published indicators (the checkout-grid query endpoint).
indicatorBySlug()(slug: string) => Promise<LibraryIndicatorSummary | null>One published indicator by slug, or null when none exists (many concepts share a slug with their catalog script; a 404 is the usual miss, not an outage).
concepts()() => Promise<LibraryConcept[]>The Financial Genome catalog (id, slug, name, family, aliases). One payload, no server-side text filter: the menu searches it locally.
script()(pineScriptCodeId: string) => Promise<string>Pine source by code id: the code-only endpoint (no session required).
scriptBySlug()(slug: string) => Promise<{ name: string; code: string }>Pine source by slug: detail first (it may inline the code), then the code-id hop (the live API returns pineScriptCode: null on detail and serves code by id only).

See also: LibraryClientOptions, LibraryIndicatorSummary, LibraryPage, LibraryQuery.

LocalIndicatorTemplatesStorage

class LocalIndicatorTemplatesStorage implements IndicatorTemplatesStorage {
    constructor(key?: string);
    list(): IndicatorTemplate[];
    save(template: IndicatorTemplate): void;
    remove(id: string): void;
}
MemberTypeDescription
constructor(key?: string)Default: key = 'velapro.indicatorTemplates'.
list()() => IndicatorTemplate[]
save()(template: IndicatorTemplate) => voidCreate or overwrite (same id).
remove()(id: string) => void

See also: IndicatorTemplate, IndicatorTemplatesStorage.

MemoryIndicatorTemplatesStorage

class MemoryIndicatorTemplatesStorage implements IndicatorTemplatesStorage {
    list(): IndicatorTemplate[];
    save(template: IndicatorTemplate): void;
    remove(id: string): void;
}
MemberTypeDescription
list()() => IndicatorTemplate[]
save()(template: IndicatorTemplate) => voidCreate or overwrite (same id).
remove()(id: string) => void

See also: IndicatorTemplate, IndicatorTemplatesStorage.

Interfaces and types

BuiltinIndicator

interface BuiltinIndicator {
    name: string;
    slug: string;
}
MemberTypeDescription
namestring
slugstringPublished library slug the Pine source is fetched under.

IndicatorFavorite

One favorite, self-sufficient for rendering: id is the stable key (native:<type> / slug:<library-slug> / source:<hash>), name what the Favorites tab shows without refetching any catalog. script is the Pine source for source: favorites: enough to re-add without a library fetch.

interface IndicatorFavorite {
    id: string;
    name: string;
    script?: string;
}

IndicatorFavoritesStorage

The persistence seam: implement it against your backend and hand it to enableIndicatorLibrary({ favorites }). load runs once at construction; save receives the full list after each (debounced) change.

interface IndicatorFavoritesStorage {
    load(): Promise<readonly IndicatorFavorite[]> | readonly IndicatorFavorite[];
    save(favorites: readonly IndicatorFavorite[]): Promise<void> | void;
}

See also: IndicatorFavorite.

IndicatorMenuItem

One row of a host section: id is the section-local stable key (e.g. a backend record id), name what the row shows.

interface IndicatorMenuItem {
    id: string;
    name: string;
}

IndicatorMenuSection

One host-supplied tab of the indicator menu (the enabler's sections option): list() names the items (called afresh on every menu open) and source(id) resolves one item's script when its row is clicked.

interface IndicatorMenuSection {
    id: string;
    label: string;
    group?: 'library';
    language?: string;
    list(): Promise<readonly IndicatorMenuItem[]> | readonly IndicatorMenuItem[];
    source(id: string): Promise<string> | string;
}
MemberTypeDescription
idstring
labelstringThe rail tab's label.
group?'library'Where the tab sits: right after Favorites by default, 'library' at the end of the Library group. A search lists the section's matches in the same place.
language?stringThe engine source(id)'s text runs on: the key it is registered under in the shells' engines option. Pine by default.
list()() => Promise<readonly IndicatorMenuItem[]> | readonly IndicatorMenuItem[]
source()(id: string) => Promise<string> | string

See also: IndicatorMenuItem.

IndicatorTemplate

interface IndicatorTemplate {
    id: string;
    name: string;
    symbol: string | null;
    timeframe: string | null;
    indicators: TemplateIndicator[];
    updatedAt: number;
}
MemberTypeDescription
idstring
namestring
symbolstring | nullThe market it carries, applied with it: null leaves the chart's market alone.
timeframestring | null
indicatorsTemplateIndicator[]
updatedAtnumber

See also: TemplateIndicator.

IndicatorTemplatesStorage

Where templates are kept. Every method may answer synchronously or with a promise.

interface IndicatorTemplatesStorage {
    list(): IndicatorTemplate[] | Promise<IndicatorTemplate[]>;
    save(template: IndicatorTemplate): void | Promise<void>;
    remove(id: string): void | Promise<void>;
}
MemberTypeDescription
list()() => IndicatorTemplate[] | Promise<IndicatorTemplate[]>
save()(template: IndicatorTemplate) => void | Promise<void>Create or overwrite (same id).
remove()(id: string) => void | Promise<void>

See also: IndicatorTemplate.

LibraryClientOptions

interface LibraryClientOptions {
    baseUrl?: string;
    fetchImpl?: typeof fetch;
}
MemberTypeDescription
baseUrl?stringOrigin (plus optional path prefix) in front of /api/library/**.
fetchImpl?typeof fetch

LibraryFamily

interface LibraryFamily {
    key: string;
    name: string;
    blurb: string;
}
MemberTypeDescription
keystringThe key the library's endpoints and concepts carry.
namestring
blurbstringOne line on what the family covers.

LibraryIndicatorSummary

One published indicator as the query endpoint lists it (the fields the menu uses).

interface LibraryIndicatorSummary {
    id: string;
    name: string | null;
    slug: string;
    pineScriptCodeId: string | null;
    family: string | null;
    imageUrl?: string | null;
    creationDateDisplayed?: string | null;
    description?: string | null;
}
MemberTypeDescription
idstring
namestring | null
slugstring
pineScriptCodeIdstring | nullThe code-only fetch key (/api/library/pinescript/{id}); null = no source.
familystring | null
imageUrl?string | nullPreview screenshot on the library CDN; null/absent when the row has none.
creationDateDisplayed?string | nullPublication date as YYYY-MM-DD: the LuxAlgo catalog sorts by this, newest first.
description?string | nullWhat the script does, a few sentences (the menu's detail pane and row summaries).

LibraryPage

interface LibraryPage {
    indicators: LibraryIndicatorSummary[];
    count: number;
}
MemberTypeDescription
indicatorsLibraryIndicatorSummary[]
countnumberTotal matches across all pages.

See also: LibraryIndicatorSummary.

LibraryQuery

interface LibraryQuery {
    text?: string;
    family?: string;
    concept?: string;
    creator?: string;
    sort?: 'name' | 'creationDateDisplayed';
    pageIndex?: number;
    pageQuantity?: number;
}
MemberTypeDescription
text?stringFree-text filter (server-side).
family?stringConcept-family key (see the library's Financial Genome roster).
concept?stringConcept slug: indicators tagged with that concept (related-by-concept).
creator?stringCreator slug: the route defaults to luxalgo when omitted.
sort?'name' | 'creationDateDisplayed'Server-side order: by name (A–Z) or by date (newest first). Absent = the library's own order.
pageIndex?number
pageQuantity?number

PineLibraryResolverOptions

Options for pineLibraryResolver.

interface PineLibraryResolverOptions {
    url: string | ((library: PineLibraryImport) => string);
    headers?: Record<string, string>;
    fetch?: typeof fetch;
}
MemberTypeDescription
urlstring | ((library: PineLibraryImport) => string)Where a library's Pine source lives: a URL template with {user}, {name} and {version} placeholders (/pine-libraries/{user}/{name}/{version}.pine), or a function building the URL from the import.
headers?Record<string, string>Request headers, e.g. an authorization header.
fetch?typeof fetchThe fetch to use; the global one by default.

From @luxalgo/vela-pinets: PineLibraryImport.

TemplateIndicator

type TemplateIndicator =
    | { kind: 'script'; name: string; script: string; inputs?: Record<string, unknown>; props?: Record<string, unknown> }
    | { kind: 'native'; name: string; type: string; inputs?: Record<string, unknown> };

TemplateTarget

What applying needs from a chart: the chart, and the shell's recorded seams where it has them.

interface TemplateTarget {
    chart: Chart;
    setSymbol?(symbol: string): void;
    setTimeframe?(timeframe: string): void;
    addIndicator(entry: { name: string; script: string; language: string; inputs?: Record<string, InputValue>; props?: Record<string, InputValue> }): void;
    addNativeIndicator(type: string): void;
}

// Unexported supporting type referenced above
type Chart = WidgetContext['chart'];

From @luxalgo/vela/plugin: InputValue, WidgetContext.

Constants

BASIC_INDICATORS

const BASIC_INDICATORS: readonly BuiltinIndicator[];

See also: BuiltinIndicator.

DEFAULT_LIBRARY_API_URL

The public LuxAlgo app origin serving /api/library/**.

const DEFAULT_LIBRARY_API_URL: 'https://app.luxalgo.com';

INDICATOR_MENU_ACTION_ID

The contributed topbar action's id. The shell's 'indicators' SLOT, taken over: registering under the built-in id replaces the native button in place and inherits the slot's whole surface (the mobile stop and the / shortcut route here, and the built-in picker dialog is not constructed). Hosts need no option: the historical indicatorPicker: false becomes redundant (kept harmless until its 0.7.0 removal).

const INDICATOR_MENU_ACTION_ID: 'indicators';

INDICATOR_TEMPLATES_ACTION_ID

const INDICATOR_TEMPLATES_ACTION_ID: 'vela-pro.indicator-templates';

LIBRARY_FAMILIES

const LIBRARY_FAMILIES: readonly LibraryFamily[];

See also: LibraryFamily.

ORDERFLOW_NATIVE_TYPES

The Orderflow tab's native roster. Mostly Pro-registered order-flow indicators; also includes Vela's core Visible Range Volume Profile (vpvr), which belongs with the other volume-profile tools rather than under Basic.

const ORDERFLOW_NATIVE_TYPES: readonly string[];

Re-exports

The following symbols are re-exported from the listed import path and documented on their primary reference page or in their upstream package.

ExportKindExported fromDocumented in
PineLibraryImportinterface@luxalgo/vela-proOwned by @luxalgo/vela-pinets
PineLibraryResolvertype@luxalgo/vela-proOwned by @luxalgo/vela-pinets

On this page