Standard Indicators and Handlers
Standard Indicators and Handlers
The TSLab API has standard, commonly used indicators. They can be easily used in their scripts. These indicators are in two places:
TSLab.Script.Helpers.Series - the class contains static methods for calculating indicators, for example, SMA, EMA, Highest, Lowest, ATR, BollingerBands and others.
TSLab.Script.Handlers - namespace that contains classes of handlers, for example MACD, ParabolicSAR, TrailStop. All these handlers are displayed as cubes in the TSLab visual editor.
Series indicators
The Series class contains some indicators, for example SMA, EMA, Highest, Lowest, ATR, BollingerBands and others.
For example, if you need to calculate the SMA indicator, then simply call the SMA method and transfer the list of prices for which you want to read (sec.ClosePrices) as the first parameter, and the calculation period will be the second parameter:
We will write a script that displays the SMA and EMA indicators on closing prices:
The red line is the SMA indicator, the blue line is the EMA.
Indicators and Handlers from Handlers
TSLab.Script.Handlers - namespace that contains classes of handlers, for example MACD, ParabolicSAR, TrailStop. All these handlers are displayed as cubes in the TSLab visual editor.
Unlike indicators from Series, you must first create an indicator object and then call the Execute method to calculate the indicator values.
Source codes of indicators: https://github.com/tslab-hub/handlers
For example, we will write a script that considers and displays the ParabolicSAR indicator on a chart:
For another example, we will write a script that buys by market and sets a trail stop. Stop will be considered a finished TrailStop class from TSLab.Script.Handlers:
As you can see, there is a deal and immediately set a trail stop (red line), which is pulled up after the price:
Last updated