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
  • Script examples. A trading system based on the RSI indicator
  • Demo materials
  • Script examples

Was this helpful?

Export as PDF
  1. Examples of scripts and indicators
  2. Examples of implementing strategies in TSLab

A trading system based on the RSI indicator

Last updated 3 years ago

Was this helpful?

Script examples. A trading system based on the RSI indicator

The relative strength index (RSI) — is a technical indicator used in the analysis of financial markets. It is intended to chart the current and historical strength or weakness of a stock or market based on the closing prices of a recent trading period. The indicator should not be confused with .

How exactly is RSI calculated in the program? It is easy to make sure that it is calculated exactly as described in wiki.

  • Finding positive (U) and negative (D) price changes.

  • Calculating the relative strength RS.

  • Based on the RS, the Relative Strength Index RSI is calculated.

The market is changing very quickly now. When the Author created the indicator, the market changes were slower and the author of the indicator used a two-week period.

To be closer to the author's calculations, it is enough to simply set a longer period on a one-minute chart, but, for the convenience of the calculation, you can use ready-made daily candles in the program by using the Compress block.

For a more detailed study of the RSI indicator calculation, you can download the demo algorithm

Download the file. In the program, open Lab | Scripts. Click the Load from file button.

Open the script for editing.

Thus, you can create algorithms for calculating indicators in the program.

The attached algorithm presents the calculation of the indicator and for comparison, the calculation of the indicator built into the program (RSIintegrated Block) is displayed on the chart. You can save your own calculation into a Self-made script.

To do this, click on the New indicator button in the Scripts window.

Please note!

  • The value of the created indicator is always output through the Return value block.

  • You can output only one value from one indicator.

  • There can be as many inputs as you want. They are performed using the Source Blocks.

  • The input to the indicator can be a number, like mine, and the indicator in the script can be used for any number.

You can also use a data source as an input. In this case, a specific bar value must be used in the indicator.

After closing the window with the indicator, the program will automatically create a self-made indicator.

The Custom folder will appear in the Script Editor Toolbar, and if there are no errors in the indicator, it will be available in this folder.

The Custom indicator can be used in any scripts you create.

In previous articles, examples were given of how you can switch from one calculation to another using an ordinary constant.

In this example, you can apply the same method. You can calculate several different averages for the indicator.

The wiki describes several signals for the indicator. Be sure to check them out if you are not already familiar with them.

For all signals, the following is true: if the indicator is high, then you should not buy, if the indicator is low, then you should not sell.

With short profit and stop loss, the price of which is calculated by trail stop in relative values.

Perhaps the momentum indicator should be added to the strategy, for entry points signals.

Parameter optimization was not carried out.

Demo materials

Please note! Demo materials and example scripts are intended only for learning TSLab.

Script examples

Demonstration algorithm for calculating RSI

Self-made RSI indicator

Indicator with a built-in switching of averaging EMA, SMA or AMA

Strategy example

Strategy example

(Download the file. In the TSLab program, open "Lab" -> "Script Manager" → Click the "Load from file" button).

As an example, ready-made blocks from the script were copied to the created indicator.

The ready-made indicator can be downloaded from the link:

In some scripts it is necessary to use one calculation, for example EMA, and in some another. In the formula, a small number will eliminate division by 0.

In the example, the following strategy is implemented: if the indicator is high, then we sell, if the indicator is low, we buy.

The second strategy : sell and close long if the indicator is high, and buy and close short if the indicator is low.

RSIcalc.tscript
RSI_calc_1.tscript
ind_RSI_calc.tscript
RSI_.tscript
RSI_trend.tscript
RSIcalc.tscript
ind_RSI_calc_1.tscript
ind_RSI_calc.tscript
RSI_.tscript
RSI_trend.tscript
relative strength
RSIcalc.tscript