Examples
Indicator Example
script({ type: 'indicator', priceStudy: true });
const length = input.integer('Length', 14);
const value = ta.rsi(close, length);
plot(value, { type: 'line', color: '#1D4E89' });
Single-Symbol Strategy Example
script({ type: 'strategy', priceStudy: true, orderSize: 1 });
const fast = series(ta.ema(close, 10));
const slow = series(ta.ema(close, 20));
if (ta.crossover(fast, slow) && strategy.param_by_id('ema', 'position') === 0) {
strategy.entry({ id: 'ema', type: 'long' });
}
Explicit Qty Override Example
script({ type: 'strategy', priceStudy: true, orderSize: 1 });
strategy.entry({ id: 'scaled_ema', type: 'long', qty: 5 });
const headerEntry = strategy.default_qty_type === 'con'
? { id: 'header_ema', type: 'long', qty: strategy.default_qty_value }
: { id: 'header_ema', type: 'long' };
strategy.entry(headerEntry);
Multi-Symbol Example
script({ type: 'strategy', priceStudy: true });
symbols([
'BTCUSDT:BINANCE:FUTURE:DEFAULT',
'ETHUSDT:BINANCE:FUTURE:DEFAULT'
]);
const btcClose = symbol.close[0].get(0);
const ethClose = symbol.close[1].get(0);
if (btcClose > ethClose) {
strategy.entry({
id: 'btc_leg',
type: 'long',
symbol: 'BTCUSDT:BINANCE:FUTURE:DEFAULT',
});
}
Practical Tip
Copy the sample closest to your goal and change one rule at a time.