TickTrader Algo API

TickTrader Algo API

Users can create their own trade bots and indicators using TickTrader.Algo.Api.
To create a custom trade bot or indicator, please follow the next steps:

  1. Install Visual Studio
  2. Install TT Algo Visual Studio Extension
  3. Follow the instructions how to create an Algo Trade Bot or Algo Indicator in Visual Studio & launch them in TickTrader terminal.

Algo Trade Bot

  1. Create a new project in Visual Studio using Empty Trade Bot template.

  2. Set the name of your Trade Bot Project (e.g. MyTradeBotTest) and click Create.

  3. In the Solution Explorer section, you’ll see the following structure:

    • MyTradeBotTest.cs: The file that contains code of the created bot.
    • README.md: The file where you can add a description of your bot in MarkDown format.


  4. If you want to use the latest version of API, check for updates in NuGet explorer, select Manage NuGet Packages for Solution...

    In the displayed window select the TickTrader.Algo.Api package > Select the your project (available if the update is) > Select the version > Click Install.

  5. After creating the Trade Bot project you will get the following template:



    Select TradeBot and press F12 to see the trading bot's functionality.


    By pressing F12 on AlgoPlugin you can see the general functionality that can be used in both bots and indicators.
  6. Bots have the following methods:

    • Init: The method will be invoked after running the bot.
    • OnStart: The method will be invoked right before the bot start.
    • OnStop: The method will be invoked when the bot stops.
    • AsyncStop: The method also will be invoked when the bot stops. You may use this method when you need to execute asynchronous code when the bot stops.
    • OnQuote: The method will be invoked with a new incoming quote.
    • OnModeTick: The method will be invoked when model tick is updated.
      Also you may use (override) the following methods in your bot:
    • OnRateUpdate: The method will be invoked with bars updating.
  7. Let's look at the example of a trade bot that you can create using Sample Trade Bot template:


    How the 'Sample Trade Bot' works: It opens a repetitive position with the selected side ('Position Side' parameter), specified volume ('Volume' parameter), waits for a period of time (set by the 'Time to wait' parameter), and then closes the open position with a Market order of the opposite side. The running bot repeats these steps until it stops.
    Note! The bot only works on TickTrader NET accounts.

  8. Build your project selecting Build Solution command in the Solution Explorer context menu.

  9. Upload a package with the created bot to Ticktrader Algo Servers: Explorer > Algo Servers > Upload Package

  10. Select the Add Bot Instance command in the context menu: select server name (local) and your trading account from the list, select the downloaded Algo Bot and enter Instance Id (optional). Click OK.

    You can change the bot's run settings and parameters on the 'Inputs' tab. Click OK to save your changes.

  11. Right-click the added bot and select the Start Bot command to run it.



Algo Indicator

  1. Create a new project in Visual Studio using Empty Indicator template.
    If necessary, install or update your version of TT Algo Visual Studio Extension by selecting Tools > Install or Update TT Algo Visual Studio Extension in TickTrader terminal. The extension installation will be automatically installed in Visual Studio.

  2. Set the name of the project (e.g. MyIndicatorTest) and click Create

  3. In the Solution Explorer section, you’ll see the following structure:

    • MyIndicatorTest.cs: The file that contains code of the created indicator.
    • README.md: The file where you can add a description of your indicator in MarkDown format.

  4. If you want to use the latest version of API, check for updates in NuGet explorer, select Manage NuGet Packages for Solution...


    In the displayed window select the TickTrader.Algo.Api package > Select the project  (available if the update is) > Select the version > Click Install.

  5. After creating the Indicator project you will get the following template:

    Select Indicator and press F12 to view the indicator's functionality.




    By pressing F12 on AlgoPlugin you can see the general functionality that can be used in both bots and indicators.



  6. There are the following methods:

    • InitThe method will be invoked, after running the indicator in Algo Studio
    • CalculateThe method will be invoked with calculations.
  7. Let's look at the example of an indicator that you can create using Sample Indicator template:



    This indicator is the simplest trend indicator based on the average price value for a selected period of time (moving average).

    • Period: price averaging period, the default is 14 (int).
    • SmoothFactor: smooth factor, which is 0.0667 by default (double).
    • Mode: calculation mode: exponential/simple (enum).
    • Input: price input.
    • Output: average price colored in red.

  8.  Build your project selecting Build Solution command in the Solution Explorer context menu.

  9. The indicator package should be placed in Algo Packages folder that can be opened by selecting Tools > Open Algo Packages folder.

  10. The indicator can be added to a chart from its context menu. Right-click the chart area and select Load Indicator > My Indicators.

  11. After the indicator is loaded you can view and configure its settings by using Indicators List > Edit Indicator context menu item.


    • Related Articles

    • TickTrader API

      The TickTrader Application Programming Interface (API) is the platform on which developers may build customized trading tools and interfaces to use with TickTrader. With APIs, you can: Get detailed information about trading symbols, user accounts, ...
    • Examples of TickTrader Algo bots

      Examples that will help you write your own bots can be found at: https://github.com/SoftFx/AlgoBots. This repository contains public indicators and bots for the Bot API: ImportAccountStateBot. This bot helps to integrate bots written on another ...
    • MQL4 to TickTrader Algo Converter

      If you have Expert Advisors or Indicators written in MQL4 (for working in MetaTrader 4), then you can use a free converter to convert them into TickTrader Algo bots and indicators. The converter is located at: ...
    • Creating a TickTrader Algo bot

      To create a TickTrader Algo bot in Visual Studio, please follow these steps: Open the installed Visual Studio 2022 application. Create a new project by selecting the following command in the Visual Studio menu: File > New > Poject. In the window you ...
    • Launching Algo indicators in TickTrader Win Terminal

      If the Ticktrader Win terminal is installed on the same machine on which you compiled the Algo package, then you can see the indicators (that are in the compiled package) in the Indicators List of this terminal. To add an Algo package to the specific ...