Comment on page

Examples of implementing strategies in TSLab


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 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. 1.
    Download a sample script to your computer.
  2. 2.
    Launch TSLab program.
  3. 3.
    Select the menu item Lab - Scripts
  4. 4.
    In the Scripts window click the Load from file button.
  5. 5.
    Go to the directory with the downloaded script. Select the required script and click on the Open button.
  6. 6.
    In the list of available scripts, select the loaded script and double-click on it with the mouse.


The examples of trading strategies written in the block programming visual editor.

The strategy is based on the ADX indicator

  • For long positions:
    • Buy if +DI > -DI and ADX rises.
    • Exit position if +DI < -DI or ADX falls.
  • For short positions:
    • To enter a short position if +DI < -DI and ADX rises.
    • To close a short position if +DI > -DI or ADX falls.
Useful links

The strategy is based on the Aroon indicator

If AroonUp is greater than AroonDown - enter the Long position and close the Short position; If AroonUp is lower than AroonDown - enter the Short position and close the Long position; If AroonUp and AroonDown approximately equal - this is a period of consolidation.
The consolidation filter for entering a position is based on the difference between two indicators, the Constant is used as the filter level
Useful links

The strategy is based on the CCI indicator

Buy when CCI rises above 100. Sell when the CCI falls below 100.
Sell (short) when CCI falls below -100. Close a short position when the CCI rises above -100.
Useful links

The strategy is based on the CCI indicator

Buy (open a long position, close a short position) when the Index of the commodity channel rises above zero.
Sell (close a long position, open a short position) when the CCI falls below zero.
Useful links

CCI Strategy Examples - Comparison

The comparison of indicators:
  • CCI built-in the TSLab program
  • CCI indicator from wiki
  • Modified CCI indicator
Useful links

Strategy without parameters

If the price has significantly changed, the market is probably trending. If the bar is large and the price moved up, then buy, if the bar is small, then exit the position.
Correspondingly, use bars with a downward direction to enter a short position.
Useful links

Strategy based on the RSI indicator

The strategy is based on the RSI indicator, if the indicator is high - sell; if the indicator is low - buy.
With a short profit and stop loss, the price of which is calculated by the trail stop in relative values.
Useful links

Strategy based on the RSI indicator - counter trend

Sell and close long if the indicator is high.
Buy and close the short if the indicator is low.
Useful links

Strategy based on the RSI indicator and the "Compress" block

Illustrates the operation of the Compress block and the daily ranges of the indicator.
Useful links

The strategy is based on the standard deviation.

The upper limit of the channel 3*Standard deviations
The lower border of the channel is -3*Standard deviations from SMA
To enter the Short position, a limit order is placed at the level of the upper border of the channel.
Exit the positions with limit orders on the average SMA.
Useful links

Trading strategy using the indicators "Maximum for the period" and "Minimum for the period".

The system is based on the breakdown of the maximum and minimum price levels for the period.
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 a position is performed by using the OSMA indicator. The simultaneous existence of opposite positions is prohibited.
Useful links

Position management strategy.

With a limited set of the maximum number of lots.
The example of using formula blocks and the EMA indicator. The example of using the "Change By" blocks.
Last modified 2yr ago