Language & inputs
AlgoCode compiles to JavaScript and runs on your chart candles. JavaScript mode runs directly. Both share the same candle data and TA helpers.
Inputs (script settings)
const len = input.int(9, { title: "Length", minval: 1 });
const src = source(input.source("close", { title: "Source" }));
const mode = input.string("EMA", {
title: "MA Type",
options: ["SMA", "EMA", "WMA"],
});Supported input types: int, float, bool, string, source, color, timeframe, time, session, symbol. Values appear in the editor Inputs panel.
Price data & series
candles— OHLCV array per barclose,open,high,low,volume,timesource("hlc3")— close, open, hl2, hlc3, ohlc4close[1]— bar history via the AlgoCode transpiler (__hist())na— useNaNfor gapsbarstate.*,syminfo.*,timeframe.*— chart context
Technical analysis library
// Moving averages ema, sma, rma, wma, vwma, dema, tema, hma, zlema, kama, trima // Bands & channels bb, keltner, donchian, envelope, stdDevBands, stdev // Oscillators rsi, macd, stoch, stochRsi, cci, mfi, williamsR, roc, trix, tsi, cmo, mom // Trend / volatility atr, adx, supertrend, parabolicSar, vwap, ichimoku // Utilities highest, lowest, crossover, crossunder, shift(values, offset)
AlgoCode ta.* calls map to these implementations. See the language reference for the full alias list.
Plotting
return [
plot(ema(close, 9), { title: "EMA", color: color.blue, lineWidth: 2 }),
plotFill(upper, lower, { color: "rgba(38,166,154,0.25)", title: "Band" }),
hline(70, { title: "Overbought" }),
plotHistogram(hist, { title: "Hist" }),
];Plotting built-ins
plot(),plotshape(),plotchar(),plotcandle()fill()→plotFill(),bgcolor(),barcolor(),hline()label.*,line.*,box.*,table.*
SuperTrend / Algobridge trend: in JavaScript use plotTrendST(tsl, trend) and plotTrendSignals(trend), or load a ready template from the toolbar. AlgoCode plotshape maps to buy/sell arrows on the chart.
Multi-timeframe & other symbols
request.security() is supported. On Run, Algocrab prefetches extra symbol/timeframe candle data. Fundamentals requests use a demo provider until a live data vendor is connected.
User-defined functions & types
- AlgoCode functions
f(x) => …transpile to JavaScript for,while,switch,enum,type/methodsupportedarray.*,map.*,matrix.*supported