TSLab
TSLab.proSupportTSLab LiveTSVerse
Eng
Eng
  • TSLab trading platform
  • For newbies
    • A beginner's guide
      • Purchasing a license key for a data provider
      • An example of connecting text quotes
      • Example of connecting a data provider to a broker / exchange
      • An example of creating a script in TSLab
      • An example of creating a trading algorithm in TSLab
  • Installing TSLab
    • TSLab Installation Guide
      • System requirements
      • TSLab Installation manual
    • Update TSLab
      • Preparing for update
      • Release build
      • Nightly build
    • Restarting the TSLab program
    • TSLab Changelog
      • TSLab 2.1 Changelog
      • TSLab 2.2 Changelog
        • 2.2.26.0 - 2024/01/31
        • 2.2.25.0 - 2024/01/17
        • 2.2.24.0 - 2024/12/04
        • 2.2.23.0 - 2024/09/19
        • 2.2.22.0 - 2024/08/30
        • 2.2.21.0 - 2024/05/17
        • 2.2.20.0 - 2024/05/15
        • 2.2.19.0 - 2024/02/21
        • 2.2.18.0 - 2024/02/09
        • 2.2.17.0 - 2023/11/16
        • 2.2.16.0 - 2023/10/20
        • 2.2.15.0 - 2023/10/13
        • 2.2.14.0 - 2023/08/11
        • 2.2.13.0 - 2023/05/12
        • 2.2.12.0 - 2023/02/28
        • 2.2.11.0 - 2022/12/15
        • 2.2.10.0 - 2022/10/27
        • 2.2.9.0 - 2022/09/16
        • 2.2.7.0 - 2022/06/23
        • 2.2.5.0 - 2022/04/29
        • 2.2.3.0 - 2022/04/01
        • 2.2.2.0 - 2021/12/29
  • Data providers
    • Cryptocurrency exchanges
      • Binance Cryptocurrency Exchange
        • Registration on Binance
          • Registration on Binance Exchange website
          • Configure Binance Wallet
          • Creating a Binance API Key for TSLab
          • Binance. Transferring USDT from wallet to wallet without commission
        • Registration on TSLab [Binance]
          • Account registration on the TSLab website [Binance]
          • Creating a free Binance Data Provider for TSLab
        • Setting up a Binance Data Provider in TSLab
        • TSLab Binance Edition
          • Starting the program
          • Configuring the Binance Data provider
      • Bitget Cryptocurrency Exchange
        • Registration on the Bitget official website
        • Creating a Free Bitget Data Provider
        • Configuring the Bitget Data Provider in TSLab
      • ByBit Cryptocurrency Exchange
        • Registration on the ByBit website
        • Creating a free ByBit data provider
        • Configuring the ByBit Data Provider in TSLab
      • Deribit Cryptocurrency Exchange
        • Deribit data provider settings
        • Deribit. Frequently asked questions and useful information
        • Deribit. Possible problems and solutions
        • Deribit Margin Requirements Calculation
        • An example of a ready-made script for Deribit
      • Kucoin Cryptocurrency Exchange
        • Registration on the KuCoin official website
        • Creating an API key on the KuCoin website
        • Issuing a free license for KuCoin Data Provider
        • Setting up the KuCoin data provider in TSLab
      • OKX Cryptocurrency Exchange
        • Setting up an OKX account
          • Registration on the OKX website
          • OKX API Key creation
          • Issuing a free license for OKX Data Provider
          • Setting up the OKX data provider in TSLab
          • OKX demo account
        • TSLab OKX Edition
          • First launch of TSLab OKEx Edition
          • Configuring the OKEx data provider
          • Trading in TSLab [OKEx]
          • OKEx Demo
    • Historical Data
      • YahooFinance
      • Offline data provider in CSV format
      • An example of connecting text quotes
      • Text files with historical data
    • Interactive Brokers
      • Getting Started with Interactive Brokers Data Provider
        • Installing and configuring the Trader Workstation (TWS) terminal
        • Installing and configuring the IB Gateway terminal
      • Features of working with Interactive Brokers data provider
      • Known issues for Interactive Brokers Data Provider
      • Loading instruments in a package
  • Working with the program
    • Main menu
      • File
        • Program Settings
      • View
        • Chart
          • Features of working with the Chart in TSLab
          • Chart Controls
        • Depth of Market
        • Quotes
        • All Trades
      • Data
        • Data Providers window
        • Add online data provider
        • Add offline data provider
      • Lab
        • Scripts window
          • Script Container
      • Trading
        • Accounts window
        • Positions window
        • My trades window
        • My orders window
          • Move orders and deals to an agent
        • Autotrading Control Center window
          • Agent window
          • Agent trading settings
            • Event recalculations
            • Slippage
          • "Forget errors" of the agent
        • Orders manager
          • Linking a manually completed order to an agent
        • Agent Control Center window
      • Tools
        • Data backup and recovery
        • Notifications manager
          • Notifications Manager Filters
          • Reference List of Service Message Numbers
          • Example of setting up notifications for Gmail
        • Export to Excel
    • Common interface
      • Status bar
      • Tab
      • Workspace
      • Spreadsheets
    • Visual editor
      • Toolbar
        • Compress and Decompress Blocks
      • List of visual blocks
        • Service Elements
        • Cycles
        • TSChannel
      • The syntax of the Formula, Boolean expression and String expression blocks.
    • Autotrading Control Center
      • Agent trade settings
        • Agent trade settings - Placing orders
        • Agent trading settings - Script execution
        • Agent trading settings - Events
    • TSLab API
      • API Introduction
        • Visual Studio Installation
        • First script (API)
        • First Indicator (API)
        • Script Debugging
        • Logging
      • Writing scripts on the API
        • Trading Instrument Data
        • Working with positions
        • List of deals
        • The order queue
        • Standard Indicators and Handlers
        • Script parameters
        • Caching
        • Local and global cache
        • Multiple Tools
      • Writing indicators on the API
        • Stream indicator
        • Bar indicator
        • Pre-processed indicator
        • Indicator with multiple calculations
      • Additional features
        • The ability to create your own optimizers *
        • C ++ / CLI script
        • API Control Panel
        • Result from script
        • * Оптимизация. Пул массивов.
      • Examples
        • Get script results
        • Get script parameters
        • Get script and agent settings
        • Get position balance (net worth)
        • An example of a strategy Breakout of the Donchian channel
        • Example of a Moving Average Crossover strategy
        • Indicator example
        • How to speed up the processing of a script on the API
        • Links to examples
      • Question - Answer
        • HandlerParameter Attribute
    • Optimization
      • Insufficient load on a multicore processor
  • Examples of scripts and indicators
    • Examples of algorithms and indicators
    • Examples of implementing strategies in TSLab
      • A trading system based on indicator CCI
      • A trading system based on Standard Deviation
      • A trading system based on Aroon
      • A trading system based on ADX and DI technical indicators
      • A trading system based on the RSI indicator
      • Example of a trading strategy without parameters
  • TSLab website
    • TSLab Support Service
      • Memory dump of TSLab application
      • TSLab program log files
Powered by GitBook
LogoLogo

Мы в соцсетях

  • Группа в Telegram
  • Новости TSLab
  • Vkontakte
  • YouTube канал TSLab Live

Наши веб-сайты

  • TSLab
  • Служба поддержки
On this page
  • Introduction
  • Simple Indicators Example
  • Exponential moving average (EMA)
  • Momentum
  • Rate of Change (RoC) - Normalized
  • Rate of Change (RoC)
  • Commodity Channel Index (CCI)
  • Converted Index of the product channel
  • Relative Strength Index
  • Modified Relative Strength Index
  • The example of implementing Ichimoku indicators
  • Simple Scripts Example
  • Manual Trading with automatic stop-loss
  • An example of using the EMA indicator
  • The example of using the ADX indicator
  • Alligator strategy, using Smoothed Moving Average (SMMA)
  • The example of using the "Maximum for a period" and "Minimum for a period" indicators.
  • The example of Hi_Lo with the use of the Compress unit.
  • The example is based on the MACD indicator, using filtering of the position entry signals.
  • Using the CMO indicator
  • The example of building a "Premium" chart.
  • An example of using the StochK indicator

Was this helpful?

Export as PDF
  1. Examples of scripts and indicators

Examples of algorithms and indicators

Introduction

DISCLAIMER

Data, information, and material (“content”) is provided for informational and educational purposes only. This material neither is, nor should be construed as an offer, solicitation, or recommendation to buy or sell any securities. Any investment decisions made by the user through the use of such content is solely based on the users independent analysis taking into consideration your financial circumstances, investment objectives, and risk tolerance. Neither www.tslab.pro nor any of its content providers shall be liable for any errors or for any actions taken in reliance thereon.

This article presents examples of the implementation of algorithms and indicators using the TSLab visual script editor.

In order to run the example, you need:

  1. Download a sample script to your computer.

  2. Launch TSLab program.

  3. Select the menu item Lab - Scripts

  4. In the Scripts window click the Load from file button.

  5. Go to the directory with the downloaded script. Select the required script and click on the Open button.

  6. In the list of available scripts, select the loaded script and double-click on it with the mouse.

Simple Indicators Example

The examples of using the block programming editor to create indicators

Exponential moving average (EMA)

Is executed using the Formula and Constant blocks.

If necessary, the user can use the Formula block instead of the Constant or another indicator for calculating the indicator's Period. This is an example of creating indicators with a managed period.

A * close + (1-A) * ema[i-1]

A = (2/(period+1))

Useful links

Download

Momentum

Momentum is calculated as the difference between the bar's closing price and the price n periods ago.

Is executed using the Formula and Constant blocks. The momentum is numerically equal to the profit that could be obtained when investing in a unit of this instrument for the period under consideration.

close - close[i-period]

Useful links

Download

Rate of Change (RoC) - Normalized

Is executed using the Formula and Constant blocks. Normalized ROC is numerically equal to the return on investment per unit of this tool for the period under consideration.

100*((close - close[i-period])/ close[i-period]

Useful links

Download

Rate of Change (RoC)

The rate of change shows the percentage change in price from one period to another. It is calculated as a comparison of the current price with the price of the previous period, which is separated from the current one by n periods. ROC is numerically equal to the increase in the cost of the instrument over the period under consideration.

((close / close[i-period])*100)-100

Useful links

Download

Commodity Channel Index (CCI)

It is calculated as the given ratio of the current deviation of a typical price from its simple moving average to the average absolute deviation of this value.

(1/0.015)*((TypicalPrice-SMA)/MAD)

TypicalPrice = (Close+Low+High)/3

MAD = SumIn(Math.Abs(TypicalPrice - SMA))/N

Useful links

Download

Converted Index of the product channel

Useful links

Download

Relative Strength Index

To calculate the relative strength, all candles of the selected time period, which showed a closing higher than the previous candle, U Calculation, are selected.

Close>Close[i-1] ? Close-Close[i-1] : 0

The average growth value is determined using the EMA exponential moving average.

The same operation is performed for candles that show a close below the previous one. Calculation D

The ratio of these two values gives the relative strength value (RS).

RSI 100-(100/(1+RS))

Made in the Formula blocks. The Associated parameter block is used.

Useful links

Download

Modified Relative Strength Index

In the given indicator there is an example of choosing the type of moving average for calculating RSI, EMA, SMA or AMA. The selection is made using the Constant.

Useful links

Download

The example of implementing Ichimoku indicators

The Ichimoku indicator is a technical indicator developed in the 1930s by Japanese analyst Goichi Hosoda, who was published under the pseudonym Sanjin Ichimoku, to predict the movement of Japan's Nikkei stock index. The Ichimoku indicator combines several approaches to market analysis and is designed to identify trends, support and resistance lines and generate buy / sell signals. Working with formula blocks.

Useful links

Download

Simple Scripts Example

The examples of using the block programming editor to create simple trading systems described in Wikipedia

Manual Trading with automatic stop-loss

The example of the application of logical constants.

You can enter positions using the buttons on the control panel. Exit positions using trailing and stop-loss blocks or using the Drop buttons.

The recommended conversion for the Recalculations by events script. Or the Transaction recalculate.

Download

An example of using the EMA indicator

The enter to the Long position at the bottom-up intersection of the short-period EMA (ema2) and the long-period EMA(ema1).

Stop loss is calculated using the Updating value Block using the formula

entry*(1+(Profit-stopValue)/100)

Where Profit - MFE% maximal deviation of the price from the entry price in the better direction.

stopValue - Constant

entry - Entry price

Useful links

Download

The example of using the ADX indicator

Enter the Long position, if DI+ is greater than DI- and the ADX value on the last closed bar is greater than the ADX value on the previous bar. adx[i-1] < adx[i]

Close the position if DI+ is less than DI- and adx[i-1] > adx[i]

Useful links

Download

Alligator strategy, using Smoothed Moving Average (SMMA)

  • «Alligator's jaw». (Jaw) This is the moving average with the longest period;

  • «Alligator's teeth». (Teeth) The second moving average with a period less than Jaw;

  • «Alligator's lips» (Lips) — the fastest one with a period less than Teeth.

Entering the Long position when the Median Price (mp) is > lips & lips > teeth & teeth > jaw Entering the Short position, when mp < lips & lips < teeth & teeth < jaw

The Exit from the positions is performed by TrailStop.

Useful links

Download

The example of using the "Maximum for a period" and "Minimum for a period" indicators.

The system is based on the breakdown of the maximum and minimum price levels over a period of time. When the current price breaks up the upper line of the channel Maximum For, enter the Long position. When the current price breaks down the lower border of the channel, enter the Short position. Exit from the positions is also performed via the Donchian channel, with other periods.

Useful links

Download

The example of Hi_Lo with the use of the Compress unit.

This example solves the problem of choosing a timeframe (an interval of bars). In the source the interval is 1 minute. Any interval greater than or multiple of a minute can be used in compression.

Useful links

Download

The example is based on the MACD indicator, using filtering of the position entry signals.

Enter the Long position if the Macd is greater than the filter Constant or less than the -Constant, when the signal line crosses the MACD indicator.

Exit the position at the reverse intersection.

Useful links

Download

Using the CMO indicator

Chande Momentum Oscillator (CMO) — modification of the Momentum indicator. Enter the Long position when the CMO crosses zero from bottom to top. Enter the Short position when the CMO crosses zero from top to bottom. Trailing stop is applied to exit positions. Assumes the presence of two opposite positions.

Useful links

Download

The example of building a "Premium" chart.

One instrument minus the second instrument. This approach is used for arbitrage strategies. In this case, spatial arbitration.

Useful links

Download

An example of using the StochK indicator

In the TSLab program all the indicators are considered "As in the book", Stochastic is no exception. In other words, no price smoothing is applied before the indicator is calculated.

In the example the SMA smoothing of the Stoch indicator is used. Constants are used to enter a position. Entering the long position when the SMA crosses the lower constant from bottom to top. Closing a position when the SMA crosses the upper constant from top to bottom.

Useful links

Download

Last updated 3 years ago

Was this helpful?

wiki

wiki

wiki

Is executed using formula blocks. The CCI example contains two more examples. calculation and calculation.

Difference from the standard indicator: EMA is used instead of , also MAD, built-in TSlab program indicator AMA, is used at calculation.

_wiki

_wiki

Moving average
Moving average EMA
EMA.tscript
Momentum
Momentum.tscript
Momentum
ROCnorm.tscript
Momentum
ROCstandart.tscript
SMA
Typical Price
Commodity channel index _wiki
Commodity channel index_ wiki
Script examples. A trading system based on indicator CCI
CCI_wiki.tscript
Typical Price
Commodity channel index _wiki
Индекс товарного канала _ wiki
Script examples. A trading system based on indicator CCI
CCI_custom.tscript
Commodity channel index _wiki
Relative Strength index
Script examples. A trading system based on indicator CCI
RSI_calc.tscript
Relative Strength index
RSI_calc_1.tscript
Ichimoku_wiki
Ichimoku.tscript
Manual Trading with automatic stop-loss.tscript
Moving_average_wiki
2MA_customStop.tscript
ADX_wiki
ADX.tscript
Moving_average_wiki
Alligator.tscript
Donchian_channel_wiki
Hi_Lo.tscript
Donchian_channel_wiki
Hi_Lo_pre-set intervals.tscript
MACD_wiki
MACD.tscript
Momentum_wiki
Momentum.tscript
Arbitration_wiki
Spot+Fut.tscript
Stochastic_wiki
StochK.tscript