Using Worksheets to Build Custom Indicators

New in Trader Beta 1.210702, Worksheets allow a person with (almost) no programming skills to compose new plots by combining existing indicators and features. Worksheets are an extension of custom Indicators. We can start a new Worksheet by selecting it from the Indicators dropdown on any chart:

When you begin a new Worksheet, you’ll be presented with this modal:

Here, you can add expressions to your Worksheet. An expression is simply an existing indicator or a combination of existing indicators combined using some mathematical operation (like addition, subtraction, etc), and defined with a Plot specification (the options below the expression). Some supported operations include:

  • Any of the JavaScript native Math object functions, such as Math.abs or Math.min.
  • Ternary expressions such as sma(10) < ema(10) ? ema(10) : sma(10)
  • Indicators as parameters to indicators, such as sma(ema(10))

To get some help with parameters and what indicators are available as expressions, start typing. Once you’ve entered some text, code-completion will attempt to search for the most relevant indicators based on your entry.

For advanced users looking to make their indicators available in Worksheets, the parameters shown in the code-completion form are named based on the names that you provide on your indicator’s module.exports object’s params field.

When you select a specific indicator while code completion is active, you’ll get additional information about that indicator. This includes a human-readable name and all the possible variations of parameters for that indicator.

A Note About Params: Notice in the image above that percentB has both period and input parameters. The value for input can be another indicator, but period cannot. We can only use other indicators as the input, not the parameters that expect single values.

Composing Multiple Indicators

To add additional indicators, click the Add More link.

As you add more expressions, you can come up with interesting things. Here’s a variation on the Alligator indicator written as a Worksheet in about 1 minute:

Advanced Features

Additional to composing indicators with ease, you can provide indicators as parameters to other indicators:

If we look at this image we can see some excellent examples of how to combine these features. Let’s look closer at some of these expressions and plot specifications:

  • In expression #2 (top), we see the combination of an sma indicator with the less-than operator. In the plot specification ‘How To Plot’ is set to Coloring. This is a powerful combination for coloring bars under a certain condition.
  • In expression #3 (middle) we see an sma being applied as a parameter to the outer sma expression, as well as an arithmetic operation (-atr(10)) being applied to the result of that expression. We can combine our indicator expressions at will, however we like.
  • In expression #4 (bottom) we see a plain number. This will just create a line at that price on the X-axis.

We hope that Worksheets will open up a new way for Traders to build unique studies without having to be particularly code-savvy, maximizing creativity while minimizing overhead and planning. Worksheets are a great way to scaffold an idea, or gauge interactions between different trends, or even just play around and discover new possibilities - be creative!