Appearance

Personalize your experience

Mode
Accent Color
Direction
Script API Reference

API Reference

IDE

This reference covers all APIs, interfaces, and utilities available to indicator, overlay, and strategy scripts in Quatick IDE.

1. Bar Data (BarData)

Every script receives an array of BarData objects — one per candle on the chart.

typescript
interface BarData {  time: number;       // Unix timestamp (seconds)  open: number;       // Opening price  high: number;       // Highest price during the bar  low: number;        // Lowest price during the bar  close: number;      // Closing price  volume: number;     // Volume traded during the bar}// Time is always in seconds since epoch (not milliseconds!)// Example: 1700000000 = Nov 14, 2023

2. Price Sources

Functions that extract a specific price from each bar:

typescript
type PriceSource = 'close' | 'open' | 'high' | 'low' | 'hl2' | 'hlc3' | 'ohlc4' | 'volume';function getPrice(bar: BarData, source: PriceSource): number {  switch (source) {    case 'close':  return bar.close;    case 'open':   return bar.open;    case 'high':   return bar.high;    case 'low':    return bar.low;    case 'hl2':    return (bar.high + bar.low) / 2;    case 'hlc3':   return (bar.high + bar.low + bar.close) / 3;    case 'ohlc4':  return (bar.open + bar.high + bar.low + bar.close) / 4;    case 'volume': return bar.volume;  }}

3.1 IIndicatorConfig

typescript
interface IIndicatorConfig {  // Identity  id: string;              // Unique slug: 'my-rsi'  name: string;            // Display name: 'My RSI'  version: string;         // Semantic version: '1.0.0'    // Visual  outputType: OutputType;  // 'LINE' | 'MULTI_LINE' | 'HISTOGRAM' | 'POINTS' | 'AREA' | 'CLOUD'  color: string;           // Primary color (CSS)  lineWidth?: number;      // Line thickness (default: 1)    // Behavior  overlay: boolean;        // true = draw on price chart, false = separate pane    // Configuration  params: IndicatorParam[];  // User-adjustable parameters}

3.2 IndicatorParam

typescript
interface IndicatorParam {  name: string;            // Parameter key: 'period', 'smoothing'  label: string;           // Display label: 'RSI Period'  type: 'number' | 'string' | 'boolean' | 'color' | 'select';  default: any;            // Default value  min?: number;            // For number type: minimum  max?: number;            // For number type: maximum  step?: number;           // For number type: step increment  options?: string[];      // For select type: choices}

3.3 IndicatorOutput

typescript
// Single value output (for LINE, HISTOGRAM, POINTS, AREA)interface IndicatorValue {  time: number;            // Must match the bar's time  value: number;           // The computed indicator value  color?: string;          // Optional per-bar color override}// Multi-line output (for MULTI_LINE)interface MultiLineOutput {  time: number;  values: Record<string, number>;  // { upper: 155, middle: 150, lower: 145 }}// Cloud output (for CLOUD)interface CloudOutput {  time: number;  upper: number;  lower: number;  fillColor?: string;     // Optional per-bar fill color}

4.1 IOverlayConfig

typescript
interface IOverlayConfig {  id: string;              // Unique slug  name: string;            // Display name  version: string;  overlay_type: OverlayType;  // 'POINT' | 'LINE' | 'SHAPE' | 'MULTIPOINT' | 'TEXT' | 'COMPLEX'  anchor: AnchorMode;     // 'data' | 'pixel' | 'percentage'  draggable: boolean;      // Can the user drag the overlay  resizable: boolean;      // Can the user resize the overlay  zIndex: number;          // Draw order (higher = on top)  opacity: number;         // Base opacity 0-1}

4.2 OverlayState

typescript
interface OverlayState {  points: DataPoint[];     // Anchor points [{time, price}] or [{x, y}]  style: OverlayStyle;     // Visual style  interaction: InteractionState;  // 'normal' | 'hovered' | 'selected' | 'dragging' | 'resizing'  userData: Record<string, any>;  // Custom data storage}interface DataPoint {  time?: number;           // For 'data' anchored overlays  price?: number;          // For 'data' anchored overlays  x?: number;              // For 'pixel' or 'percentage' anchored  y?: number;              // For 'pixel' or 'percentage' anchored}

5.1 Configuration

python
# Strategy metadata dictionarymetadata = {    'name': 'My Strategy',    'version': '1.0.0',    'author': 'Your Name',    'description': 'A description of the strategy',}# Risk management configurationconfig = {    'initial_capital': 100000.0,       # Starting capital    'position_size_pct': 2.0,          # % of capital per trade    'max_positions': 5,                # Maximum concurrent positions    'stop_loss_pct': 2.0,              # Stop loss percentage    'take_profit_pct': 4.0,            # Take profit percentage    'commission_pct': 0.1,             # Commission percentage    'slippage_pct': 0.05,              # Slippage percentage    'use_trailing_stop': False,        # Enable trailing stop    'trailing_stop_pct': 1.5,          # Trailing stop distance}

5.2 Signal Types

python
from enum import Enumclass Signal(Enum):    BUY = 'BUY'    SELL = 'SELL'    CLOSE = 'CLOSE'    HOLD = 'HOLD'# Signal object returned from generate_signal()signal_output = {    'signal': Signal.BUY,    'price': 150.00,    'time': 1700000000,    'reason': 'RSI crossed below 30 — oversold',    'stop_loss': 147.00,    'take_profit': 156.00,    'size': None,  # None = use config.position_size_pct}

6. Canvas 2D API (Render Context)

The render function receives a CanvasRenderingContext2D allowing full Canvas 2D :

typescript
// Key Canvas 2D APIs used in rendering:ctx.save()                    // Save current statectx.restore()                 // Restore saved state// Lines & Pathsctx.beginPath()               // Start a new pathctx.moveTo(x, y)              // Move cursorctx.lineTo(x, y)              // Draw line to pointctx.arc(x, y, r, 0, Math.PI*2) // Draw circle/arcctx.rect(x, y, w, h)         // Draw rectangle pathctx.closePath()               // Close current path// Stroke & Fillctx.stroke()                  // Draw path outlinectx.fill()                    // Fill path interiorctx.fillRect(x, y, w, h)     // Filled rectanglectx.strokeRect(x, y, w, h)   // Outlined rectanglectx.clearRect(x, y, w, h)    // Clear area// Stylectx.strokeStyle = '#color'    // Line colorctx.fillStyle = '#color'      // Fill colorctx.lineWidth = 2             // Line thicknessctx.setLineDash([5, 5])       // Dashed line patternctx.globalAlpha = 0.5         // Opacity (0-1)ctx.lineCap = 'round'         // Line end stylectx.lineJoin = 'round'        // Line join style// Textctx.font = '12px Inter'       // Fontctx.textAlign = 'left'        // 'left' | 'center' | 'right'ctx.textBaseline = 'top'      // 'top' | 'middle' | 'bottom'ctx.fillText('text', x, y)    // Draw textctx.measureText('text').width  // Measure text width

7. Coordinate Conversion

Scripts receive a toPixel function to convert coordinates (time, price) to pixel coordinates on the canvas:

typescript
// toPixel converts data point to canvas coordinatestype ToPixelFn = (point: { time: number; price: number }) => { x: number; y: number };// Usage in render functions:function render(ctx, state, toPixel) {  const pixel = toPixel({ time: 1700000000, price: 150.50 });  ctx.fillRect(pixel.x - 2, pixel.y - 2, 4, 4);  // Draw a 4x4 dot}// Reverse: toData converts pixel coordinates back to datatype ToDataFn = (pixel: { x: number; y: number }) => { time: number; price: number };// Usage in hit testing:function hitTest(mouseX, mouseY, state, toPixel) {  const p = toPixel(state.points[0]);  const distance = Math.sqrt((mouseX - p.x) ** 2 + (mouseY - p.y) ** 2);  return distance < 10;  // 10px tolerance}

8. Available Python Packages

These packages are pre-installed or can be installed via the Python Packages :

PackageVersionUse
1.26+Numerical computation, array operations
2.1+DataFrames for OHLCV
scipy1.11+ functions, signal processing
scikit-learn1.3+Machine learning models
ta-lib buildTechnical analysis indicators (SMA, , , MACD, etc.)
statsmodels0.14+ models, analysis
!
Caution:Not all Python packages are compatible with . C- packages must be specially compiled for WebAssembly. The package manager will show an error if a package is incompatible.

Related articles

  • 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…

  • Quatick Script SDK Reference

    Coding / IDE / Reference

    The Quatick IDE injects the SDK directly into TypeScript indicator, overlay, and strategy scripts at Apply time. You do not import SDK functions. Use the…

  • Writing Indicators in the IDE

    Coding / IDE / Indicators

    Copy the template below into a new Indicator file, click Run to calculate, then Apply to draw it on the chart.

  • Writing Overlays in the IDE

    Coding / IDE / Overlays

    Overlays are visual elements drawn on top of the price chart. They include annotations, zones (supply/demand, support/resistance), drawing tools, and custom…

  • Coding for Trading — Fundamentals

    Coding / Fundamentals

    The concepts every strategy rests on, whether you write it in the condition builder or in code: series, bar indexing, the difference between a value and a…

  • 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…

  • 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…

  • Quatick IDE — Getting Started

    Coding / IDE / Getting Started

    Quatick IDE is a browser-based development environment for creating custom trading indicators, overlays, and automated strategies. Scripts are written in…

  • Script Best Practices

    Coding / IDE / Best Practices

    Follow these guidelines to write performant, reliable, and maintainable trading scripts.

Browse all knowledge base articles →