Appearance
Personalize your experience
SDK Reference
IDEThe Quatick IDE injects the SDK directly into TypeScript indicator, overlay, and strategy scripts at Apply time. You do not import SDK functions. Use the globals directly, or use namespaced helpers such as ta.sma(), math.round(), array.push(), and color.rgb().
Runtime Model
1function calculate(bars) {2 const fast = ta.ema(close, 9);3 const slow = ta.sma(close, 21);45 plot(fast, { label: 'EMA 9', color: color.cyan });6 plot(slow, { label: 'SMA 21', color: color.amber });78 return bars.map((bar, i) => ({ time: bar.time, value: fast[i] }));9}Data Globals
Every script receives the current chart as both raw bars and precomputed series arrays.
| Global | Type | Description |
|---|---|---|
| bars | BarData[] | Full bars in chart order. Each bar has time, open, high, low, close, and volume. |
| time | number[] | Bar timestamps aligned with bars. |
| open | number[] | Open prices aligned by index. |
| high | number[] | High prices aligned by index. |
| low | number[] | Low prices aligned by index. |
| close | number[] | Close prices aligned by index. |
| volume | number[] | Volume values aligned by index. Missing volume is normalized to 0. |
1function calculate() {2 const range = high.map((value, i) => value - low[i]);3 const avgRange = ta.sma(range, 20);45 return bars.map((bar, i) => ({6 time: bar.time,7 value: avgRange[i],8 }));9}Output Model
Indicators can return chart-ready series manually, or use () helpers and let the collect the first plottable series for the chart overlay.
| Pattern | Shape | When to Use |
|---|---|---|
| Array return | [{ time, }, ...] | Primary overlay line with complete control over the returned series. |
| Object return | { series: [{ time, }, ...] } | When returning or a named output wrapper. |
| () | (number[], ) | Scripts that compute one or more arrays and want simple output collection. |
| plotBand() | plotBand(upper, lower, ) | /envelope for rich renderers; first line remains chart-compatible today. |
function calculate() {
const bb = ta.bb(close, 20, 2);
plot(bb.middle, { label: 'BB Middle', color: color.white });
plotBand(bb.upper, bb.lower, { label: 'BB Range', color: color.new(color.blue, 0.2) });
}Namespaces
| Namespace | Examples | Description |
|---|---|---|
| ta | ta.sma(), ta.(), ta.bb(), ta.crossover() | Technical analysis helpers. |
| math | math.abs(), math.(), math.clamp() | Math namespace mapped to math helpers. |
| array | array.new(), array.push(), array.avg() | Mutable array helpers. |
| color | color.rgb(), color.new(), color.from_gradient() | Callable color function plus color constants and transforms. |
function calculate() {
const signalLine = ta.ema(close, 9);
const distance = close.map((price, i) => math.round(price - signalLine[i], 2));
const values = array.new(0);
array.push(values, distance[distance.length - 1]);
plot(distance, { label: 'Distance', color: color.from_gradient(distance.at(-1) ?? 0, -10, 10, color.red, color.green) });
}Moving Averages
| Function | Signature | Description |
|---|---|---|
| sma | sma(data, period): number[] | Simple moving average. |
| ema | ema(data, period): number[] | . |
| wma | wma(data, period): number[] | Linearly weighted moving average. |
| dema | dema(data, period): number[] | Double with reduced lag. |
| tema | tema(data, period): number[] | Triple with further lag reduction. |
| vwma | vwma(price, volume, period): number[] | Volume-weighted moving average. |
| hma | hma(data, period): number[] | Hull moving average. |
| smma | smma(data, period): number[] | -style smoothed moving average. |
| zlema | zlema(data, period): number[] | Zero-lag EMA using lag-compensated input. |
| alma | alma(data, period?, offset?, sigma?): number[] | Arnaud Legoux moving average. |
| kama | kama(data, period?, fast?, slow?): number[] | Kaufman adaptive moving average. |
| t3 | t3(data, period?, vFactor?): number[] | Tillson T3 moving average. |
| lsma | lsma(data, period, offset?): number[] | Least-squares moving average. |
| mcgd | mcgd(data, period?): number[] | McGinley Dynamic average. |
| trima | trima(data, period): number[] | Triangular moving average. |
| vidya | vidya(data, cmoPeriod?, emaPeriod?): number[] | Variable Index Dynamic Average. |
Oscillators
| Function | Signature | Description |
|---|---|---|
| rsi | rsi(data, period?): number[] | . |
| stochastic / ta.stoch | stochastic(high, low, close, k?, d?, smooth?): { k, d } | Stochastic oscillator. |
| stochRsi | stochRsi(data, rsiPeriod?, stochPeriod?, k?, d?): { k, d } | Stochastic RSI. |
| connorsRsi | connorsRsi(data, rsiPeriod?, streakPeriod?, rankPeriod?): number[] | Connors RSI oscillator. |
| cci | cci(high, low, close, period?): number[] | Commodity Channel Index. |
| williamsR | williamsR(high, low, close, period?): number[] | Williams Percent R. |
| mfi | mfi(high, low, close, volume, period?): number[] | Money Flow Index. |
| tsi | tsi(data, long?, short?): number[] | True Strength Index. |
| ultimateOscillator | ultimateOscillator(high, low, close, p1?, p2?, p3?): number[] | Larry Williams Ultimate Oscillator. |
| dpo | dpo(data, period?): number[] | Detrended Price Oscillator. |
| aroon | aroon(high, low, period?): { up, down, oscillator } | Aroon trend timing oscillator. |
| rvi | rvi(open, high, low, close, period?): { value, rvi, signal } | Relative Vigor Index. |
| cmo | cmo(data, period?): number[] | Chande Momentum Oscillator. |
| ppo | ppo(data, fast?, slow?, signal?): { ppo, signal, histogram } | . |
| fisherTransform | fisherTransform(high, low, period?): { fisher, signal } | Fisher transform oscillator. |
| awesomeOscillator | awesomeOscillator(high, low, fast?, slow?): number[] | Awesome Oscillator from price. |
Momentum
| Function | Signature | Description |
|---|---|---|
| macd | macd(data, fast?, slow?, signal?): { macd, signal, histogram } | Moving Average Convergence Divergence. |
| momentum | momentum(data, period?): number[] | Difference from N bars ago. |
| roc | roc(data, period?): number[] | Rate of Change . |
| adx | adx(high, low, close, period?): { adx, plusDI, minusDI } | Average Directional Index. |
| dmi | dmi(high, low, close, period?): { diPlus, diMinus } | Directional movement indicator. |
| trix | trix(data, period?): number[] | Triple-smoothed rate of change. |
| elderRay | elderRay(high, low, close, period?): { bullPower, bearPower } | Elder Ray bull and bear power. |
| coppockCurve | coppockCurve(data, wmaLength?, longROC?, shortROC?): number[] | Long-term momentum oscillator. |
| schaffTrendCycle | schaffTrendCycle(data, fast?, slow?, stoch?): number[] | MACD-derived cycle oscillator. |
| balanceOfPower | balanceOfPower(open, high, low, close): number[] | Balance of Power candle momentum. |
| priceOscillator | priceOscillator(data, fast?, slow?): number[] | Fast MA minus slow MA. |
Volatility
| Function | Signature | Description |
|---|---|---|
| trueRange / ta.tr | trueRange(high, low, close): number[] | per bar. |
| atr | atr(high, low, close, period?): number[] | . |
| bollingerBands / ta.bb | bollingerBands(data, period?, multiplier?): { upper, middle, lower } | SMA plus/minus bands. |
| keltnerChannel / ta.kc | keltnerChannel(high, low, close, emaPeriod?, atrPeriod?, multiplier?): { upper, middle, lower } | plus/minus . |
| standardDeviation | standardDeviation(data, period): number[] | . |
| donchianChannel | donchianChannel(high, low, period?): { upper, middle, lower } | and lowest low channel. |
| choppiness | choppiness(high, low, close, period?): number[] | Choppiness Index. |
| supertrend | supertrend(high, low, close, period?, multiplier?): { value, supertrend, direction } | -based and direction. |
| parabolicSar | parabolicSar(high, low, start?, increment?, maximum?): number[] | Parabolic stop-and-reverse. |
| historicalVolatility | historicalVolatility(data, period?, annualFactor?): number[] | Annualized volatility from log returns. |
Volume
| Function | Signature | Description |
|---|---|---|
| obv | obv(close, volume): number[] | On-Balance Volume. |
| vwap | vwap(high, low, close, volume): number[] | Volume Weighted Average Price. |
| vwapBands | vwapBands(high, low, close, volume, devMultiplier?): { vwap, upper1, lower1, upper2, lower2 } | VWAP with deviation bands. |
| adLine | adLine(high, low, close, volume): number[] | Accumulation/Distribution line. |
| cmf | cmf(high, low, close, volume, period?): number[] | Chaikin Money Flow. |
| chaikinOscillator | chaikinOscillator(high, low, close, volume, fast?, slow?): number[] | spread of accumulation/. |
| forceIndex | forceIndex(close, volume, period?): number[] | Elder Force Index. |
| easeOfMovement | easeOfMovement(high, low, volume, period?): number[] | Ease of Movement. |
| nvi | nvi(close, volume): number[] | Negative Volume Index. |
| pvi | pvi(close, volume): number[] | Positive Volume Index. |
| klinger | klinger(high, low, close, volume, short?, long?, signal?): { klinger, ko, signal } | Klinger Volume Oscillator. |
Statistics
Scalar compute a single from the supplied arrays. helpers return per-bar arrays.
| Function | Signature | Description |
|---|---|---|
| mean | mean(values): number | Arithmetic mean. |
| median | median(values): number | Median value. |
| variance | variance(values, ddof?): number | Sample or population variance. |
| stdDev | stdDev(values, ddof?): number | scalar. |
| correlation | correlation(a, b): number | Pearson correlation. |
| covariance | covariance(a, b, ddof?): number | Covariance scalar. |
| linearRegression | linearRegression(x, y): { slope, intercept, r2 } | Ordinary least-squares regression. |
| percentile | percentile(values, percent): number | Percentile from 0 to 100. |
| zscore | zscore(data, period): number[] | z-score. |
| skewness | skewness(values): number | skew. |
| kurtosis | kurtosis(values): number | Excess . |
| rollingCovariance | rollingCovariance(a, b, period, ddof?): number[] | covariance. |
| rollingCorrelation | rollingCorrelation(a, b, period): number[] | Rolling correlation. |
Utility
| Function | Signature | Description |
|---|---|---|
| crossover | crossover(a, b): boolean[] | True where a crosses above b. |
| crossunder | crossunder(a, b): boolean[] | True where a crosses below b. |
| highest / lowest | highest(data, period): number[] | high or low. |
| highestBars / lowestBars | highestBars(data, period): number[] | Bars since high or low. |
| na | na(value): boolean | Null, undefined, or NaN test. |
| nz | nz(value, replacement?): number | Replace missing numeric values. |
| change | change(data, length?): number[] | Difference from length bars ago. |
| sum | sum(data, period): number[] | . |
| fixnan | fixnan(data): number[] | Forward-fill NaN values. |
| valuewhen | valuewhen(condition, source, occurrence?): number[] | of source at a prior condition occurrence. |
| barsSince | barsSince(condition): number[] | Bars since condition was last true. |
| pivotHigh / pivotLow | pivotHigh(data, left, right): (number | null)[] | Confirmed swing pivots. |
| falling / rising | falling(data, length): boolean[] | Strict run checks. |
| stdev | stdev(data, period): number[] | Alias for . |
| dev | dev(data, period): number[] | mean absolute deviation. |
| avgTrueRange | avgTrueRange(high, low, close, period?): number[] | Alias for . |
Levels
| Function | Signature | Description |
|---|---|---|
| pivotPoints | pivotPoints(high, low, close, type?): PivotPointLevels | Standard, Fibonacci, Camarilla, or Woodie pivots. |
| fibRetracement | fibRetracement(swingHigh, swingLow, levels?): FibLevels | map by ratio. |
| fibExtension | fibExtension(a, b, c, levels?): FibLevels | map projected from three . |
| ichimoku | ichimoku(high, low, close, tenkan?, kijun?, senkou?, chikou?): IchimokuCloud | Tenkan, Kijun, Senkou A/B, and Chikou arrays. |
| supportResistance | supportResistance(high, low, close, lookback?, strength?): { support, resistance } | Clustered pivot support/resistance levels. |
| priceChannels | priceChannels(high, low, period?): { upper, lower, middle } | Highest/lowest channel. |
| linearRegressionChannel | linearRegressionChannel(data, period, deviations?): { regression, upper, lower } | regression channel. |
| zigzag | zigzag(high, low, deviation?, depth?): { points, pivots } | Swing and pivot array. |
| volumeProfile | volumeProfile(high, low, close, volume, priceLevels?): VolumeProfileLevel[] | Volume buckets by price level. |
Candle Patterns
| Function | Returns | Description |
|---|---|---|
| isDoji(open, high, low, close, threshold?) | boolean[] | Tiny body relative to full range. |
| isHammer(open, high, low, close) | boolean[] | Long lower wick bullish . |
| isInvertedHammer(open, high, low, close) | boolean[] | Long upper wick inverted hammer . |
| isShootingStar(open, high, low, close) | boolean[] | Alias for inverted- . |
| isMarubozu(open, high, low, close, threshold?) | { bull, bear } | Full-body candles with tiny wicks. |
| isEngulfing(open, high, low, close) | { bull, bear } | Bullish and bearish engulfing bodies. |
| isHarami(open, high, low, close) | { bull, bear } | Inside-body bullish and bearish . |
| isMorningStar(open, high, low, close) | boolean[] | Three-candle bullish reversal. |
| isEveningStar(open, high, low, close) | boolean[] | Three-candle bearish reversal. |
| isThreeWhiteSoldiers(open, close) | boolean[] | Three rising bullish candles. |
| isThreeBlackCrows(open, close) | boolean[] | Three falling bearish candles. |
| isInsideBar(high, low) | boolean[] | Current range inside previous range. |
| isOutsideBar(high, low) | boolean[] | Current range outside previous range. |
| isSpinningTop(open, high, low, close) | boolean[] | body with upper and lower wicks. |
Math
| Function | Alias | Description |
|---|---|---|
| mathAbs(value) | math.abs() | Absolute . |
| mathSign(value) | math.() | Returns -1, 0, or 1. |
| mathMax(...values) | math.max(...values) | Maximum . |
| mathMin(...values) | math.min(...values) | Minimum . |
| mathClamp(value, min, max) | math.clamp(, min, max) | Clamp into range. |
| mathCeil(value) | math.ceil() | up. |
| mathFloor(value) | math.() | down. |
| mathRound(value, decimals?) | math.(, decimals?) | with optional decimals. |
| mathLog(value) | math.log() | logarithm. |
| mathLog10(value) | math.log10() | Base-10 logarithm. |
| mathExp(value) | math.exp() | e to the . |
| mathPow(base, exponent) | math.pow(base, exponent) | Power. |
| mathSqrt(value) | math.sqrt() | . |
| mathSin/Cos/Tan(value) | math.sin/cos/tan() | Trigonometry in radians. |
| mathRandom(min?, max?) | math.random(min?, max?) | Random in range. |
| mathLerp(a, b, t) | math.lerp(a, b, t) | Linear interpolation. |
Arrays
| Function | Namespace Alias | Description |
|---|---|---|
| arrayNew(size?, initialValue?) | array.new() | Create an array. |
| arrayPush(arr, value) | array.push() | Push and return the same array. |
| arrayPop(arr) | array.pop() | Pop last . |
| arrayShift(arr) | array.shift() | first . |
| arrayUnshift(arr, value) | array.unshift() | Insert first . |
| arrayGet(arr, index) | array.get() | Get by index; negative indexes count from end. |
| arraySet(arr, index, value) | array.set() | Set by index and return the array. |
| arraySize(arr) | array.size() | Length. |
| arrayAvg/Sum/Max/Min(arr) | array.avg/sum/max/min() | Numeric summaries. |
| arraySort(arr, order?) | array.sort() | Sorted copy. |
| arrayReverse(arr) | array.reverse() | Reversed copy. |
| arrayIncludes(arr, value) | array.includes() | Membership test. |
| arrayIndexOf(arr, value) | array.indexof() | First matching index. |
| arraySlice(arr, start, end?) | array.slice() | Slice copy. |
| arrayConcat(...arrays) | array.concat() | Concatenate arrays. |
| arrayClear(arr) | array.() | in place. |
| arrayFill(arr, value, start?, end?) | array.fill() | Fill in place. |
Time & Sessions
| Function | Description |
|---|---|
| barTime(index?) | Timestamp for the current bar, an absolute index, or a negative offset from the current bar. |
| barIndex() | Current . In whole-chart Apply this is the last bar. |
| barYear/barMonthOfYear/barDayOfMonth(timestamp?) | Date components for a timestamp or current bar. |
| barDayOfWeek/barHour/barMinute/barSecond(timestamp?) | Weekday and time components. |
| isMarketHours(exchange?) | check for NSE, BSE, NYSE, NASDAQ, or . |
| isPremarket(exchange?) / isPostmarket(exchange?) | checks where the exchange supports them. |
| isWeekend(timestamp?) | Weekend test. |
| toTimestamp(year, month, day, hour?, minute?) | Build a timestamp. |
| formatDate(timestamp, format?) | Format using tokens like YYYY, MM, DD, HH, mm, ss. |
Drawing & Alerts
| Function | Description |
|---|---|
| plot(data, options?) | Collect a line series. The first plottable series is applied to the current chart. |
| plotHistogram(data, options?) | Collect . |
| plotArea(data, options?) | Collect area series . |
| plotHLine(price, options?) | Collect a record. |
| plotBand(upper, lower, options?) | Collect an upper/lower . |
| bgcolor(color, options?) | Collect chart color intent. |
| barcolor(color) | Collect candle/bar color intent. |
| drawLine/drawBox/drawLabel(...) | Collect records for support. |
| alertCondition(condition, title, message?) | Collect an record when condition is true. |
| debugLog(...args) | Write to the IDE output logs. |
| createWebGLLayer(id, options?) | Create a -compatible layer object with drawLine, drawFill, drawHeatmap, drawRect, drawText, and . |
Colors
| Function / Constant | Description |
|---|---|
| color(r, g, b, a?) / color.rgb(r, g, b, a?) | Build an rgba() color string. |
| hslColor(h, s, l, a?) / color.hsl(h, s, l, a?) | Build an hsla() color string. |
| hexToRgba(hex, ?) | Convert #RGB or #RRGGBB to rgba(). |
| colorFromGradient(, min, max, fromColor, toColor) | Interpolate between two colors. |
| colorBlend(colorA, colorB, t) / color.blend(...) | Blend colors by t from 0 to 1. |
| colorTransparency(color, ) / color.new(color, alpha) | Apply to a color. |
| COLOR_CYAN, COLOR_RED, COLOR_GREEN, COLOR_AMBER, COLOR_PURPLE, COLOR_ORANGE, COLOR_WHITE, COLOR_GRAY, COLOR_BLUE, COLOR_PINK | Global constants also available as color.cyan, color.red, etc. |
Strategy Helpers
| Function | Description |
|---|---|
| signal(direction, quantity?, price?, tag?) | Record a buy, sell, or close signal. |
| position() | Return current position info. |
| equity() | Return current equity estimate. |
| strategyEntry(id, direction, quantity?, price?, comment?) | Entry helper. |
| strategyExit(id, fromEntry, profit?, loss?, limitPrice?, stopPrice?) | Exit helper. |
| strategyClose(id, comment?) | Close one logical entry. |
| strategyCloseAll(comment?) | Close all position state. |
| strategyCancel(id) | Compatibility helper for intent. |
| maxDrawdown() | compatibility helper. |
Examples
1// Multi-factor overlay with global helpers2function calculate() {3 const trend = ta.supertrend(high, low, close, 10, 3);4 const fast = ta.ema(close, 9);5 const slow = ta.ema(close, 21);6 const bullishCross = ta.crossover(fast, slow);78 const lineColor = bullishCross[bullishCross.length - 1]9 ? color.green10 : trend.direction.at(-1) === 1 ? color.cyan : color.red;1112 plot(trend.value, { label: 'Supertrend', color: lineColor, lineWidth: 2 });13}1// Candle pattern scanner2function calculate() {3 const engulf = isEngulfing(open, high, low, close);4 const hammer = isHammer(open, high, low, close);56 const score = close.map((_, i) => {7 if (engulf.bull[i] || hammer[i]) return 1;8 if (engulf.bear[i]) return -1;9 return 0;10 });1112 plotHistogram(score, { label: 'Pattern Score', color: color.purple });13}1// Strategy with returned signals for chart markers/backtest2function run(bars) {3 const fast = ta.ema(close, 12);4 const slow = ta.ema(close, 26);5 const buy = ta.crossover(fast, slow);6 const sell = ta.crossunder(fast, slow);78 const signals = [];9 for (let i = 1; i < bars.length; i++) {10 if (buy[i]) signals.push({ time: bars[i].time, type: 'BUY', price: close[i], reason: 'EMA cross up' });11 if (sell[i]) signals.push({ time: bars[i].time, type: 'SELL', price: close[i], reason: 'EMA cross down' });12 }1314 return { signals, trades: [] };15}Related articles
Related to Quatick Script SDK Reference
- Indicator Reference
Automation / Strategy Builder / Reference
All 94 indicators the strategy engine computes, grouped as in the builder's picker, with their parameters, outputs and the range of values each output can take.
- Built-in Indicators & Overlays
Coding / IDE / Reference
Quatick ships with a full library of pre-built indicators and overlays. You can use these out of the box, or study their implementations as reference for…
- Python Scripting with Pyodide
Coding / IDE / Python
Quatick strategies run in Python 3.11 via Pyodide — a full CPython compiled to WebAssembly. This means your strategies execute entirely in the browser, with…
- Script API Reference
Coding / IDE / Reference
This reference covers all APIs, interfaces, and utilities available to indicator, overlay, and strategy scripts in Quatick IDE.
- Backtesting in Python and C++
Backtesting / SDKs
The quatick Python package and the header-only C++ library let you import indicators, backtest on your own machine and send the same file to Quatick.…
- Book vs Tape Profile
Trading / Order Book / Views
What is resting at each price beside what has actually traded there — intent against action.
- High-Low
Charts / Chart Types / Bar Charts
The simplest bar variant — a vertical line connecting the period high and low with no open or close ticks. High-low charts reduce price action to its purest…
- IDE Keyboard Shortcuts
Coding / IDE / Keyboard
Quatick IDE supports extensive keyboard shortcuts inspired by VS Code. Shortcuts are organized by area. On macOS, replace Ctrl with ⌘ and Alt with ⌥ where…
- Projection
Charts / Drawing Tools / Forecasting
A forward-looking cone or fan that projects future price movement based on current trend and volatility. Projections help visualize potential price paths,…