Common indicator properties
Each technical indicator has its own set of properties and methods regarding its calculations and visual appearance. All of these properties can be modified both via user interface and in code. See Modifying indicators to learn how.
However, there are many common properties that most indicators have. This section introduces these properties and methods to use them.
Line color
Line color adjusts the color of the indicator line. In code, setLineColor() method can be used for this. If the indicator contains several lines, each line has its own method. Furthermore, if the indicator consists of bars instead of lines, for instance in case of a histogram, the method name will be setBarColor() respectively.
Line width
Line width adjusts the width of the indicator line. In code, setLineWidth() method can be used for this. If the indicator contains several lines, the same method affects all the lines. In other words, the lines of the indicator always have the same line width.
Moving average type
Many indicators use moving averages in their mathematical formulas. LightningChart JS Trader allows choosing between several averaging types, which lets you to create custom versions of the indicators. Use setMovingAverageType() method to change the average. Available options include Exponential, Hull, Simple, Time Series (Least Squares), Triangular, Variable Index Dynamic Average (VIDYA), Variable, Volume-Weighted and Weighted averages, as well as Welles Wilder's Smoothing.
Offset
Offset moves the indicator from its calculated position forward or backward. For example, offset 1 moves the indicator one time period forward while offset -1 moves it one time period backwards. Use setOffset() method to set this in code. Note that modifying offset for an indicator does not affect other indicators using it as a source.
Period count
Many indicators are based on a specific number of past time periods. For instance, a Simple Moving Average with period count 10 takes the price values of the ten latest time periods and calculates their average. Period count, in code setPeriodCount() method, is used to adjust this number of time periods.
Source
Source allows changing the values the indicator is based on. For example, you can modify indicator calculations to be based on High or Low values instead of Close values. LightningChart JS Trader also allows using other indicator values as a source. For instance, you can have a Simple Moving Average based on an Exponential Moving Average. In code, use setSource() method to set this.
Note that it is possible to create source loops by setting several indicators to be based on each other (i.e. indicator A based on indicator B, B based on C, and C based on A). LightningChart recognizes this situation and forces the indicators' source settings back to default options in order to prevent the application from freezing or crashing.
Source is available for indicators only when their mathematical formula allows it.
Label type
When any indicator is added to the chart, a label showing the latest indicator value is created automatically. Label type, setValueLabelType() in code, allows modifying what parts of the label are shown. Available options include showing only the label, the horizontal line across the chart, showing both, and hiding the whole label. Note that the main chart's show value labels setting has to be enabled to show indicator specific labels.
Visible
Visible, in code setVisible() method, allows hiding and showing the indicator. Note that hiding an indicator does not remove it from the chart. Use dispose() to delete the indicator. Furthermore, if a study indicator (indicator below the price chart) is hidden, its segment still remains visible.