Reference
Generated from source — do not hand-edit. Rendered from backtest-engine/src/indicator-script.ts by pnpm --filter docsite gen:reference; a test fails when it drifts.

Indicator script API

An indicator script is a module that exports config (an IndicatorScriptConfig) and calculate(data, params). The chart renders the declared plots from calculate()’s output keys; strategies can call the same indicator by its slug via ctx.indicator(). See Indicators for a walkthrough.

IndicatorScriptModule

Member Type Description
config IndicatorScriptConfig
calculate (data: OHLCV[], params: Record<string, number>): Record<string, (number | null)[]>
Declaration
interface IndicatorScriptModule {
	config: IndicatorScriptConfig;
	calculate(data: OHLCV[], params: Record<string, number>): Record<string, (number | null)[]>;
}

IndicatorScriptConfig

Member Type Description
name string
pane 'overlay' | 'separate'
params Record<string, IndicatorScriptParam>
plots IndicatorScriptPlot[]
Declaration
interface IndicatorScriptConfig {
	name: string;
	pane: 'overlay' | 'separate';
	params: Record<string, IndicatorScriptParam>;
	plots: IndicatorScriptPlot[];
}

IndicatorScriptParam

Member Type Description
default number
min? number
max? number
step? number
Declaration
interface IndicatorScriptParam {
	default: number;
	min?: number;
	max?: number;
	step?: number;
}

IndicatorScriptPlot

Member Type Description
key string
kind 'line' | 'histogram' | 'dots'
color? string
width? number
Declaration
interface IndicatorScriptPlot {
	key: string;
	kind: 'line' | 'histogram' | 'dots';
	color?: string;
	width?: number;
}