Beta 1.210702 Indicators using Worksheets

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:

Multiple-Value Indicators

A single expression on a worksheet can only produce a single line, bar, or color change. If you want another line, bar, or coloring, you need to add an expression as detailed above. So how then, can we handle multi-value indicators such as Bollinger Bands, or Keltner Channels? You may notice when you try to use these expressions that they don’t render. But not to worry, you just need to map each of the individual outputs.

Try adding a multi-line indicator to your worksheet. The produced value is actually an object with fields equivalent to the return of an indicator’s map outputs. In the case of Bollinger Bands, we have lower and upper fields:

We simply need to add a second expression for the upper value. At first that may seem odd, but you’ll quickly notice that this grants us even more freedom than using classic indicators - you could change how the upper and lower bands are mapped individually for instance.

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!