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
  • External option C# script
  • External C# script
  • Return value
  • Import double values
  • Import bool values
  • Import int values
  • Source (value, non-streaming)
  • Source (value, streaming)
  • Source (Interactive spline)
  • Source (boolean)
  • Source (Option series)
  • Source (Position)
  • Commentary
  • Control panel
  • Control message
  • Boolean expression
  • Heartbeat 2
  • Not tradable instrument
  • Not tradable option
  • Updatable value
  • One to many linked parameters
  • Window
  • Chart pane
  • Data Grid Panel
  • Canvas Panel
  • Recalc Scheduler
  • Linked parameter
  • Event
  • Message
  • String expression
  • Tradable instrument
  • Tradable option
  • Formula
  • Timestamp
  • Export values

Was this helpful?

Export as PDF
  1. Working with the program
  2. Visual editor
  3. List of visual blocks

Service Elements

External option C# script

Custom code in C# language (for working with options).

Block Parameters

  • Scripts - Select external scripts (Location)

Block Inputs

  • Financial instrument (unlimited number)

Block outputs

No outputs

External C# script

Custom code in C# language

Parameters

  • Scripts - Select external scripts (Location)

Block Inputs

  • Financial instrument (unlimited number)

Block outputs

No outputs

Return value

The block is available in the indicator editor.

Sets the return value of the indicator.

Parameters

Without parameters

Block Inputs

  • Financial instrument (unlimited number), Number, Number (Integer), Boolean value, Two numbers, Cluster, Interactive line, Option, Option series, Single option, Surface, Trading statistics, Last trading statistics

Block outputs

No outputs

Import double values

Returns a Double value, according to the identifier set in the Export values block.

Parameters

  • Identifier

Block Inputs

  • Financial instrument

Block outputs

  • Number

Import bool values

Returns a Boolean value, according to the identifier set in the Export values block.

Parameters

  • Identifier

Block Inputs

  • Financial instrument

Block outputs

  • Boolean value

Import int values

Returns an integer, according to the Identifier set in the Export values block.

Parameters

  • Identifier

Block Inputs

  • Financial instrument

Block outputs

  • Number (Integer)

Source (value, non-streaming)

The block is available in the indicator editor.

A not streaming source of numbers.

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Number

Source (value, streaming)

The block is available in the indicator editor.

A streaming source of numbers.

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Number

Source (Interactive spline)

The block is available in the indicator editor.

Source - interactive spline. This block represents a graph in the form of a curve passing through the specified points.The received data can be displayed on the canvas panel ("Canvas Panel"). This data type is returned by such blocks as "Prepare a line", "IV Smile", "Smile' of Black-Scholz".

The line's color, thickness, type and its transparency are configured in the scripts’ editor. Each node has such additional settings as the color of the node, the symbol and the size of the symbol in the node. You can attach a tooltip to a node (using a block that forms a line) and a label (permanently visible text).

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

Source (boolean)

The block is available in the indicator editor.

The source of boolean values.

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Boolean value

Source (Option series)

The block is available in the indicator editor.

The data source “optional series”. It includes all options of all strikes with one expiration date.

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Option series

Source (Position)

The block is available in the indicator editor.

To get the values from the Position block (for example, the Entry price, the number of bars held, etc).

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Position

Commentary

Allows you to write a text comment and link it to any block.

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

No outputs

Control panel

The block is available in the script and indicator editor

A panel where you can add control elements that regulate the parameters of blocks’ optimization.

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

Not defined

Control message

Displays a control message

Parameters

  • True message - true message

  • False message - false message

  • Message - message

Block Inputs

  • Boolean value

Block outputs

No outputs

Boolean expression

The Boolean Expression block is a custom indicator that has an unlimited number of inputs of the "Number" or "Boolean Value" type. The names of the blocks connected to the "Formula" block are variables. The output value is a "Boolean Value". The syntax of the C# programming language is used to construct logical formulas.

Parameters

  • Expression - Opens the Formula editor window.

  • Begin with - Shows which bar to start the calculation from.

Block Inputs

  • Boolean value and Numbers

Block outputs

  • Boolean value

You can find the available operators and mathematical functions of the language at the following links - C# operators, Mathematical functions built into the C# language.

Examples

Heartbeat 2

Automatic forced recalculation of the script after a specified period of time. The forced recalculation is started via the Recalc() method in the API. By default, protection is enabled so that the recalculation does not start more often than 300ms. You can bypass this in the API by launching the method Recalc(true).

Parameters

  • Interval - interval

Block Inputs

No inputs

Block outputs

No outputs

Not tradable instrument

A non-tradable data source.

Pay attention! Duplication of one tool by several sources is not allowed.

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Financial instrument

Not tradable option

Optional non-tradable data source. This includes the underlying asset and all options on it (all series and all strikes).

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Option

Updatable value

A block that allows you to accumulate data on position. After the position is closed, it is reset to zero. A typical application is the implementation of a custom trail-stop. When used without a position, the value will be global.

Parameters

  • Initial - setting the initial value of the block.

  • Do not Clear - Prevents the block from being cleared to the initial value when the position is closed.

  • Execution order - Defines the queue for calculating the Updated value in the algorithm, in the general order (by default), at the end of the algorithm (in the queue of this calculation branch) or after leaving the position.

Block Inputs

  • Number - a new value that is written to the block;

  • Logical value - condition - whether or not we update the numeric value;

  • Cleaning (optional parameter), logical value - brings the updatable value to the starting value.

Block Outputs

  • A current value in the block.

Examples

One to many linked parameters

An analogue of the “Linked parameter” block, but it allows you to transfer the same value to several blocks at once. In the block properties, you must manually define and link the parameters to each other.

Parameters

Detected automatically

Block Inputs

  • Boolean value

  • Number

Block outputs

No outputs

Window

Creates an additional window in the lab where the chart panels can be displayed.

Parameters

Without parameters

Block Inputs

  • Control Panel, Graph

Block outputs

No outputs

Chart pane

Creates a chart panel.

The block is available in the script and chart editor.

Parameters

Without parameters

Block Inputs

  • Number

  • Boolean value

  • Financial instrumen

Block outputs

  • Chart. It can be used with the Window block.

Data Grid Panel

Allows to create a data table. For example, the structure of an option position. The format and name of the columns are edited (in a separate Table Editor).

Parameters

  • Layout

    • Property

      • Format

      • Header

      • Visibility

      • Text alignment

Block Inputs

  • Number

Block Outputs

  • Table. Can be used with the Window block.

Canvas Panel

A panel with the X and Y axes, on which you can output non-time-bound data.

Parameters

Without parameters

Block Inputs

  • Number

Block outputs

  • Chart. It can be used with the Window block.

Recalc Scheduler

Automatic forced recalculation of the script at the specified system time of the computer. Works on a running agent. For large intervals of the main recalculation, do not forget that when changing the parameter, you need to restart the agent or to output the parameter to the control panel, with the recalculation flag, in advance.

Parameters

  • Time - The time, up to a millisecond, when the script will be recalculated.

Block Inputs

  • Financial instrument, Option, Option series

Block outputs

  • Number

Linked parameter

Allows you to link the parameters of different blocks together so that they are not repeated in the optimization list. It is necessary that the parameters should always have the same value.

Parameters

  • Detected automatically

Block Inputs

  • Master - Number, Boolean value

  • Slave - Number, Boolean value

Block outputs

No outputs

Event

During the next recalculation, if the specified event is executed, the Event block will return the value true. This value can be used in the algorithm. The block can be used many times in the editor. The block connects to the source, returns an event for the tool.

Parameters

  • Event type - Event type: None, Order rejected, Order filled, Position opening, Position closing, Order quantity changed, Trading is started, Trading is stopped, Order canceled, Pretrade limitation.

Block Inputs

  • Financial instrumen

Block outputs

  • Boolean value

Message

When the value “true” appears at the input of the block outputs a user message to the program log. You can use label (Tag) in the filters of the Tools - Notification Manager window.

Parameters

  • Message - Message

  • Tag - Additional user tag

  • Importance - The importance of the message (Info, Warning, Error)

Block Inputs

  • Boolean value

Block outputs

No outputs

String expression

String expression - a custom indicator that has an unlimited number of inputs of the "Number" or "Boolean value" type. The names of the blocks connected to the "Formula" block are variables. The output value is " String Value". The syntax of the C# programming language is used to construct logical formulas.

Parameters

  • Expression - Opens the formula editor window

  • Start with - Shows which bar to start the calculation from.

Block Inputs

  • Number, Boolean value

Block outputs

  • String value

Tradable instrument

A tradable data source.

Pay Attention! Duplication of one tool by several sources is not allowed.

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Financial instrumen

Tradable option

An optional tradable data source. This includes the underlying asset and all options on it at once (all series and all strikes).

Parameters

Without parameters

Block Inputs

No inputs

Block outputs

  • Option

Formula

The formula is a custom indicator that has an unlimited number of inputs of the "Number" or "Boolean Value" type. The blocks connected to the "Formula" block are variables. The output value is a "Number". The syntax of the C# programming language is used to construct formulas.

When you type the name of a cube, a list of cubes that match the text you are typing will appear in the formula editor. You can go to the list using the "Down" button, or by clicking the left mouse button directly in the list. The selection of a cube from the list is carried out by pressing the "Enter" button or by double-clicking the mouse. After selecting a cube from the list, the expression is supplemented with the selected cube.

You can find the available operators and mathematical functions of the language at the following links:

Parameters

  • Expression - Opens the Formula editor window.

  • Start with - Shows which bar to start the calculation from.

Block Inputs

  • Number, Boolean value

Block outputs

  • Number

Examples

Timestamp

Parameters

Without parameters

Block Inputs

  • Financial instrumen

Block outputs

  • Number

Example

11/01/2019 11:16 The local time UTC + 3 in a one-minute period corresponds to 1547205360000, at the close of the bar the number 1547205360000 (Fri Jan 11 2019 11:16:00 UTC).

Export values

Passes the value by the identifier set by the user.

Parameters

  • Identifier

Block Inputs

  • Financial instrumen

  • Number, Boolean value

Block outputs

  • Number

Last updated 3 years ago

Was this helpful?

Time in Unix Time Stamp format with milliseconds (Number of milliseconds from 70th year). Feature: the block returns a number without conversions, regardless of the "Local Time" settings in the data provider. The block gives the corresponding UTC time/date in the UTS format on the bar.

https://currentmillis.com/
C# operators and expressions - C# referencedocsmsft
Logo
Math Class (System)docsmsft
Logo
20KB
ADX.tscript
Example of the ADX indicator
25KB
Alligator_tradable.tscript
Example of the Alligator indicator
22KB
Momentum.tscript
Example of the Momentum indicator
38KB
2MA_customStop.tscript
Example of a 2MA strategy with a non-standard stop
38KB
2MA_customStop.tscript
Example of a 2MA strategy with a non-standard stop