Quickstart
On this page
CodeLab has a terse, top-level way to write indicators: no class, no boilerplate. You write a body, it renders. It looks a lot like Pine Script, but it’s plain ChartLabs TypeScript.
Open the editor
CodeLab runs entirely in your browser. Nothing to install, no CLI, no local Node required.
- Open CodeLab. Head to chartlabs.co/codelabs. If you’re not logged in, sign up (the free plan is enough).
- Start a script. Pick a template (Quick Start is a good first one) or start a new script.
- Hit Run. CodeLab compiles the script. Errors and warnings show in the Console under the editor.
- Add it to the chart to see it draw on live data. For a strategy, open the Backtest tab to see its trades and equity curve.
Your first indicator
This is a complete, working indicator: a moving-average crossover with buy/sell markers. Paste it into a new CodeLab file and Run it.
import { indicator, ta, plot, plotShape, close } from '@chartlabs/script-sdk';
export default indicator('EMA Cross', { placement: 'overlay' }, () => {
const fast = ta.ema(close, 12); // 12-period EMA of the close
const slow = ta.ema(close, 26); // 26-period EMA
// Give every plot its own title. Untitled plots are named after their
// series, so two untitled EMAs would end up sharing one layer.
plot(fast, { title: 'Fast EMA', color: '#2b8aef' }); // blue
plot(slow, { title: 'Slow EMA', color: '#ef5350' }); // red
// Buy/Sell markers where the fast EMA crosses the slow EMA:
plotShape(ta.crossover(fast, slow), { title: 'Buy', shape: 'triangleup', location: 'below', color: '#26a69a' });
plotShape(ta.crossunder(fast, slow), { title: 'Sell', shape: 'triangledown', location: 'above', color: '#ef5350' });
});Run & publish
Hit Run to compile, then Add to Chart to see it render against live data in the sandboxed runtime. When you’re happy, Publish shares it to the marketplace. The class-based extends Lab form is still fully supported for per-bar state and advanced lifecycle hooks: see Class-form indicators.