Technical analysis methods
Technical Analysis Charts include TechnicalAnalysisMethods class which contains all the mathematical formulas used to calculate technical indicators. Users can use these formulas for example to create their own custom indicators.
To use Technical Analysis Methods in code, first import the class from lcjs-trader module ("@lightningchart/lcjs-trader") and then create a new class instance in code. The class cannot be used without a reference to the TradingChart due to some of the calculations requiring access to the trading data added to the chart. Therefore, a TradingChart instance has to be created before using Technical Analysis Methods.
// Using Technical Analysis Methods to calculate Rate of Change based on High values.
// Importing the class.
import { TechnicalAnalysisMethods } from "@lightningchart/lcjs-trader";
// Create TradingChart instance before using Technical Analysis Methods.
const tradingChart = ta.tradingChart({loadFromStorage: false, colorTheme: Themes.turquoiseHexagon})
// Getting the current dataset.
const dataset = tradingChart.getData(false)
// Using the methods to create a custom indicator.
const taMethods = new TechnicalAnalysisMethods(tradingChart)
const rocValues = taMethods.calculateRateOfChange(dataset[2] as number[], 10)
if (rocValues != null) {
const cs = tradingChart.indicators().addCustomStudy()
cs.setData(rocValues)
}