Public

Your first indicator with My scripts

With My scripts you create your own indicators. If you know a little JavaScript, you have your first one in five minutes.

1. Open the editor

Tap the </> button in the top bar. On a phone, the editor slides up from the bottom.

2. Create a new script

Tap New script. It starts with this template:

defineIndicator({
  name: 'Two EMAs',
  placement: 'price',
  inputs: [input.number('fast', 'Fast', 9), input.number('slow', 'Slow', 21)],
  outputs: [output.line('fast', 'Fast', 'series1'), output.line('slow', 'Slow', 'series2')],
  calc(c, i) {
    return { fast: ta.ema(c.close, i.fast), slow: ta.ema(c.close, i.slow) };
  }
});

3. Save and add it

Ctrl+S checks the script; if there is an error, it tells you which. Then tap Add to chart.

4. Change it

Try ta.sma instead of ta.ema, or add an RSI in its own pane with placement: 'pane'. Every time you save, the chart updates by itself.

Your scripts run in an isolated space of your browser: they cannot touch your account or the internet.

Read the full API reference