Tradovate

Build a Custom Indicator in Tradovate (JavaScript)

None of Tradovate's built-in studies draw quite what you want? Here's how to code your own indicator in JavaScript with the Code Explorer, from a two-line offset to a real moving average.

Verificato dal Trading Systems Team di PickMyTrade Ultimo aggiornamento
· 7 min read
Tradovate Code Explorer module docked in the workspace showing the indicator file tree and editor

You've clicked through Tradovate's built-in studies and none of them draws quite what you want. Good news, you can write your own. The whole platform runs on JavaScript, charts included, and it hands you an open editor called the Code Explorer where you code an indicator, save it, and drop it on a chart like any built-in study. This walks you through it, from a two-line offset to a real moving average.

What Are Tradovate Custom Indicators?

Tradovate Trader runs the same JavaScript across web, desktop, and mobile, so the charting engine and every built-in study are JavaScript under the hood. Custom indicators just expose that same API to you. An indicator is a small module that exports two things: a name that identifies it, and a calculator class with a map() method. map() takes each bar in the series and returns a number, and the chart plots it. Start from scratch, copy a built-in and tweak it, or install one someone else uploaded, and the values can run on a chart or show on the DOM.

Build a Custom Indicator: Step-by-Step

1

Open the Code Explorer Module

The editor lives inside the platform as its own panel. Add the Code Explorer module to your workspace, the same way you'd add a chart or a DOM, drag it in from the module list. Once it's docked, you've got a file tree of Tradovate's own indicator source on one side and an editor on the other. That built-in source is your best cheat sheet: open a study you like and read how it's put together.

2

Start a New Indicator File

With the Code Explorer focused, open File → New from the top bar. That gives you a blank editor to type into. Nothing's wired up yet, an empty file won't show anywhere until you export a proper definition, which is the next step.

3

Write the Calculator

Here's the smallest indicator that actually does something, a line offset a fixed amount below price. Say you want a rough stop-loss reference sitting two points under each bar, see the code example below. Two moving parts: the module.exports block registers the indicator, name is a machine ID (keep it plain), and calculator points at your class. The class needs at least a map() method. Tradovate calls it once per bar, walking the whole series; d.value() gives you that bar's input value, and whatever you return gets plotted. Save the file and it shows up in the chart's indicator list as EXAMPLEOFFSET, the name in uppercase, drawing a plain line below price.

4

Add Inputs and Reuse Built-in Tools

A fixed number is limiting. Real indicators take user inputs, and you rarely need to write the math by hand. Tradovate bundles a tools folder full of ready-made algorithms you pull in with require. Here's a complete exponential moving average built on the included EMA helper, with an adjustable period, see the code example below. A few new pieces: require pulls in predef, Tradovate's shared parameter and style presets, plus the EMA algorithm from the tools folder, the same source you can open in the Code Explorer. init() runs once before the loop to build the EMA calculator at your chosen period; map() then feeds each bar's value into it. The params line adds an adjustable period field defaulting to 10, schemeStyles paints the line red, and tags files it under "My Indicators" in the menu.

5

Save It and Add It to Your Chart

Save the file and switch to a chart. Open the Indicators list, find your indicator by its uppercase name, and add it like any built-in study. If it took a period, you'll see that field in its settings, ready to change per chart. Prefer not to code at all? Tradovate also lets you Explore Community Indicators, browse studies other traders have shared, check the details and download count, and install one straight into your indicator menu in a couple of clicks.

Tradovate Code Explorer with the File menu open and the New option highlighted

class offset {
    map(d) {
        return d.value() - 2.0;
    }
}

module.exports = {
    name: "exampleOffset",
    calculator: offset
};

JavaScript offset indicator code in the Tradovate Code Explorer editor

const predef = require("./tools/predef");
const EMA = require("./tools/EMA");

class ema {
    init() {
        this.emaAlgo = EMA(this.props.period);
    }

    map(d) {
        return this.emaAlgo(d.value());
    }
}

module.exports = {
    name: "exampleEma",
    description: "My EMA",
    calculator: ema,
    params: {
        period: predef.paramSpecs.period(10)
    },
    tags: ["My Indicators"],
    schemeStyles: predef.styles.solidLine("red")
};

EMA custom indicator using require to import Tradovate's built-in EMA tool in the editorCustom indicator selected in the Tradovate chart Indicators list and plotted on the chart

Prefer Signals Over Syntax?

Coding an indicator gives you a custom view of the market, but an indicator only draws. It can't pull the trigger. If your goal is to act on a signal the moment it fires, that's a different job: PickMyTrade routes your TradingView alerts straight to Tradovate as live orders, so your strategy trades itself.

Automate Your Tradovate Entries

An indicator only draws, it can't pull the trigger. PickMyTrade routes your TradingView alerts straight to Tradovate as live orders, so your strategy trades itself.

Start Your Free 5-Day Trial

Frequently Asked Questions

A little helps, but you don't have to start from a blank page. The Code Explorer ships with the source for Tradovate's own studies, so the easiest path is to open one that's close to what you want, copy it, and change the parts you understand. The two examples above, an offset line and a moving average, are about as simple as it gets.

No. A custom indicator only calculates values and plots them on the chart or DOM. It can't send orders on its own. To act on a signal automatically you need a separate automation layer that watches for the condition and routes the order.

This guide is for educational and informational purposes only and is not financial, investment, or trading advice. Trading futures and other leveraged products carries a substantial risk of loss and is not suitable for every investor. PickMyTrade is an independent third-party automation platform and is not affiliated with, endorsed by, or sponsored by Tradovate, Inc. "Tradovate" and all related names, logos, and trademarks are the property of their respective owners. Platform features and steps change over time, so always confirm the current process in the official Tradovate platform and documentation before acting.