Getting Started
The fastest public path from a first indicator to a first working strategy.
Beginner
Getting Started
Start with one of two shapes:
- an indicator that plots a value
- a strategy that also places trades
1. Build An Indicator
script({ type: 'indicator', priceStudy: true });
const length = input.integer("Length", 14);
const rsiValue = ta.rsi(close, length);
plot(rsiValue, { type: "line", color: "#1D4E89", linewidth: 2 });
This gives you:
- a script header
- a user-editable input
- a calculation
- a plot on the chart
2. Build A Strategy
script({ type: 'strategy', priceStudy: true, orderSize: 1 });
const fastLen = input.integer("Fast Length", 10);
const slowLen = input.integer("Slow Length", 20);
const fast = ta.ema(close, fastLen);
const slow = ta.ema(close, slowLen);
const fastSeries = series(fast);
const slowSeries = series(slow);
if (ta.crossover(fastSeries, slowSeries) && strategy.param_by_id("ema", "position") === 0) {
strategy.entry({ id: "ema", type: "long" });
}
if (ta.crossunder(fastSeries, slowSeries) && strategy.param_by_id("ema", "position") !== 0) {
strategy.exit({ id: "ema" });
}
3. Keep The First Version Small
- use one or two inputs
- validate one signal at a time
- plot the key line before adding trade logic
- copy a sample script when you want a known-good pattern
4. Common Failure Modes
- using indicator math directly on raw numbers instead of series values
- forgetting to keep a stable trade id for entry and exit
- mixing legacy
$...syntax into a new script - trying to add too many signals before the first version works