Docssdk
Scripting Reference
High-level reference map for script structure, namespaces, and the public authoring surface.
Reference
Scripting Reference
This page is the entry point for the reference section. Use it when you need the shape of the language before moving into method-by-method pages.
Script Header
script({
type: 'strategy',
priceStudy: true,
initialCapital: 100000,
orderSize: 50,
orderType: 'poe',
commission: 0.05,
commissionType: 'per',
slippage: 0,
marketType: 'crypto',
resolution: '15',
tradeBelowCash: false,
});
Public Script Surface
| Surface | What it is |
|---|---|
script({...}) |
Script identity and platform settings |
| built-in series | open, high, low, close, volume, time |
input.* |
User-configurable inputs |
series(...) |
Historical wrapper for derived values |
plot(...) |
Chart output |
strategy.* |
Order and position helpers |
ta.* |
Indicator and signal library |
math.* |
Numeric helpers |
symbols([...]) and symbol.* |
Multi-symbol basket surface |
Core Patterns
close,open,high,low,volume, andtimeare series- use
.get(0)for the current bar and.get(1)for the previous bar - wrap derived values with
series(...)when you need crossover helpers - keep all platform settings in a single
script({...})block - use object-style
strategy.entry({ ... })andstrategy.exit({ ... })
const fast = series(ta.ema(close, 10));
const slow = series(ta.ema(close, 20));
Multi-Symbol Surface
symbols([
'BTCUSDT:BINANCE:FUTURE:DEFAULT',
'ETHUSDT:BINANCE:FUTURE:DEFAULT',
]);
const btcClose = symbol.close[0].get(0);
const ethFast = ta.ema(symbol.close[1], 8);
Strategy Defaults
strategy.default_qty_value;
strategy.default_qty_type;
strategy.initial_capital;
Use these when a script needs to read the configured header defaults. If an entry omits qty, the engine uses orderSize and orderType. If an entry provides qty, that explicit value overrides the header default.
Where To Go Next
- Platform Settings for the
script({...})header - Built-In Methods Reference for globals, inputs, plotting, and math helpers
- Strategy API for
strategy.* - TA Library Reference for
ta.* - Multi-Symbol Strategies for public basket usage
Complete Example
script({ type: 'strategy', priceStudy: true, orderSize: 1 });
const fastLen = input.integer('Fast', 10);
const slowLen = input.integer('Slow', 20);
const fast = series(ta.ema(close, fastLen));
const slow = series(ta.ema(close, slowLen));
if (ta.crossover(fast, slow) && strategy.param_by_id('ema', 'position') === 0) {
strategy.entry({ id: 'ema', type: 'long' });
}
if (ta.crossunder(fast, slow) && strategy.param_by_id('ema', 'position') !== 0) {
strategy.exit({ id: 'ema' });
}
plot(ta.ema(close, fastLen), { type: 'line', color: '#D65A31' });
plot(ta.ema(close, slowLen), { type: 'line', color: '#1D4E89' });