Built-in Tools

View as Markdown

Indicator Tutorial 5

A major part of the indicator can be reused by other indicators. The application includes tools folder with a set of reusable classes and functions. Indicators can import them via require construction of Javascript.

For example, our EMA can be rewritten as this one:

1const predef = require("./tools/predef");
2const EMA = require("./tools/EMA");
3
4class ema {
5 init() {
6 this.emaAlgo = EMA(this.props.period);
7 }
8
9 map(d) {
10 return this.emaAlgo(d.value());
11 }
12}
13
14module.exports = {
15 name: "exampleEma",
16 description: "My EMA",
17 calculator: ema,
18 params: {
19 period: predef.paramSpecs.period(10)
20 },
21 tags: ["My Indicators", predef.tags.MovingAverage],
22 schemeStyles: predef.styles.solidLine("red")
23};

Source codes of the tools folder are available via the Code Explorer module of the application.