Indicators

My scripts

Write your own indicators with the TradingCurve editor.

With My scripts you create your own indicators in JavaScript, with the TradingCurve indicator API.

Open the editor

  • The </> button in the top bar, or
  • Indicators > My scripts > Open the editor.

On a computer the editor opens as a panel on the right; on a phone it slides up from the bottom.

Your first script

  1. Tap New script. It starts with a two EMA template.
  2. Change the code. The colors help you read it: comments, text, numbers and the API functions.
  3. Save (Ctrl+S) checks the script. If it has an error, you see it below with its explanation.
  4. Add to chart puts it on the active chart.

When you save it again, the chart updates by itself.

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

Everything you can use is in the API reference.

Where they are saved

With an account, your scripts are saved to your account (up to 50). Without one, in this browser (up to 20).

Security

Your scripts run in an isolated space of your browser: they cannot use the internet, cookies, storage or your session. If a script takes too long (for example, a loop that never ends), it is stopped and does not run again until you fix it and save it.

Why not Pine Script

Pine Script is TradingView's own language and only works there; every platform has its own. TradingCurve uses JavaScript, the most widely known language in the world, with its own API. If you bring an indicator from Pine, the logic usually carries over almost as is: ta.ema, ta.rsi, crosses and the rest have their equivalent.