Trading bots

IMPORTANT NOTE: Trading Bots are currently a Beta feature, which means that certain issues are still to be expected. We've done our best in order to iron out all the problems, but still we can't claim that it's guaranteed to eb stable. Please be cautious and double-check your bots.

The trading bots in TrendSpider is a powerful functionality that allows the traders to fully automate the order execution with a broker or exchange via webhooks, receive live notifications, and post in a private chat room or to social media. In this documentation, we will explore:

  • Creating a Bot Strategy
  • Create a Trading Bot
  • Setting Up a Trading Bot
  • On-Chart Signal Marks
  • Verify Trading Bot Functionality
  • Manage Trading Bots
  • Current Limitations
  • Changing or Downgrading Plan
  • Best Practices of Using Trading Bot

Let’s get started 🚀

Creating a Strategy

Before you can start setting up the trading bot, it is a prerequisite to have a strategy in the first place. You can create a Strategy in the Strategy Tester. Please refer to the documentation - Creating a New Strategy to learn more about how to create strategies using a strategy tester.

Create a Strategy

Create a Trading Bot

There are three methods to navigate to the Trading Bot Configuration for setting up your trading bot:

Method 1: Using the “Alerts & Bots” Option from the Top Toolbar

Method 2: Using Strategy Tester

Method 3: Using Trading Bot Widget

Method 1: Using “Alerts & Bots Option” from the Top Toolbar

Step 1: Click on the vertical ellipsis adjoining the Alerts & Bots button

vertical ellipsis adjoining the Alerts & Bots button

Step 2: Select Create a Trading Bot option from the dropdown list.

Select Create a Trading Bot option

The window for creating the trading bot will appear. You can select your strategy from the dropdown and complete setting up your trading bot through this window.

start setting up your trading bot

NOTE: Strategy selector box only contains strategies that are not read-only.

Method 2: Using Strategy Tester

Step 1: Click on the Strategy Tester button from the top-right corner of the top menu bar.

Click on the Strategy Tester button

Step 2: Load any of your strategies from the Strategy List in the left panel (or create and configure a new one) and click on the RUN button to run the backtest.

Load any of your strategies from the Strategy List

Step 3: Click on the Launch as Trading Bot button (which appears as soon as the test of a strategy has been completed) at the top-right corner of the tester.

Click on the Launch as Trading Bot button

The window for creating the trading bot will appear. The strategy selected in the Step 2 above will be automatically picked and you can configure the rest of the settings to complete setting up your trading bot.

The window for creating the trading bot will appear

**NOTE: Strategy selector box only contains strategies that are not read-only. So if you are testing a strategy that is read-only and then tries to create a bot from it, then your Strategy box won’t have it pre-selected.

Method 3: Using Trading Bot Widget

Step 1: Click on the Sidebar button from the top-right corner of the interface.

Click on the Sidebar button

Step 2: Select Add or Remove Widgets from the dropdown.

Select Add or Remove Widgets

Step 3: Click on the Add New Widget button at the bottom of the side panel

 Click on the Add New Widget button

Step 4: Select Trading Bots from the list.

Select Trading Bots from the list.

Step 5: Click on the Done button and the trading bots widget will be added to the sidebar.

Click on the Done button

Step 6: Click on the Create a Bot button.

Click on the Create a Bot button.

The window for creating the trading bot will appear. You can select your strategy from the dropdown and complete setting up your trading bot through this window.

select your strategy from the dropdown

You can also click on the vertical ellipsis from the top of the trading bot widget and select the option- Create a Trading Bot from the dropdown list.

select the option- Create a Trading Bot

Setting Up a Trading Bot

After navigating to the Bot configurations settings, you can set up and create your trading bot. The below-provided instructions explain every property you can set up while creating a bot.

Bot Name

Provide a name to your trading bot. We’ll auto-generate a name for you, in case you don’t want to invent one.

Strategy

Select your backtesting strategy from the dropdown.

Time Frame

Select the time frame for which you want the trading bot to check the criteria. For example, if the time frame selected is 1 hour, then the trading bot will check for the criteria after each hourly candle is closed.

Limitation

  • Trading bots can only work on time frames from 15 minutes to Daily.
  • On short days bots created on the Daily time frame won’t trigger at 13:00 and will trigger at 16:00 instead.

Notifications

Select the mode with which you are most comfortable in receiving the notifications whenever your trading bot enters or exits a position.

You can select any combination or all of the following modes for receiving the notifications:

  • SMS: If enabled, then you will receive the corresponding notifications to the cell phone number defined in your Account Notification settings
  • Email: If enabled, then you will receive the corresponding notifications to the email address defined in your Account Notification Settings.
  • Webhook: if enabled, then we’ll send HTTP POST requests to the webhook you provide (see below).
Webhook

Selecting Webhook as the notification preference will require you to define the following two criteria for entry webhook and exit webhook.

  • Webhook URL/Endpoint
  • Webhook Body (Enter it in the format your destination server expects to receive when a signal is sent to it)

NOTE: Your webhook provider should be capable of executing orders on a post-market. You won’t have any signals executed on the last candle of a day otherwise.

Selecting Webhook as the notification preference

The table below provides the list of documents explaining the instructions for establishing a Webhook connection between TrendSpider and third-party applications:

Documents Reference
Direct Connection with Slack Using Webhook https://help.trendspider.com/articles/direct-connection-with-slack-using-webhook
Direct Connection with Alertatron Using Webhook https://help.trendspider.com/articles/direct-connection-with-alertatron-using-webhook
Direct Connection with Discord Using Webhook https://help.trendspider.com/articles/direct-connection-with-discord-using-webhook
Direct Connection with TradersPost Using Webhook https://help.trendspider.com/articles/direct-connection-with-traderspost-using-webhook
Direct Connection with SignalStack Using Webhook https://help.trendspider.com/articles/direct-connection-with-signalstack-using-webhook
Connection with Zapier Using Webhook https://help.trendspider.com/articles/connection-with-zapier-using-webhook
Connection with IFTTT Using Webhook https://help.trendspider.com/articles/connection-with-ifttt-using-webhook
Connection with Make Using Webhook https://help.trendspider.com/articles/connection-with-make-using-webhook
Connection with Workato Using Webhook https://help.trendspider.com/articles/connection-with-workato-using-webhook
Connection with Elastic Using Webhook https://help.trendspider.com/articles/connection-with-elastic-using-webhook

NOTE: You can also choose to skip configuring the notifications, but in this case, the SMS option will be selected by default. However, if you choose to disable all the notification modes, then you will not receive any notification whenever your trading bot will enter or exit a position.

Control Notifications

Control notifications play an instrumental role in providing you with insights into the behavior of the trading bot. They explain every step of a trading bot (even if the step is “do nothing at this time”).

Critical Only Control Notification: Selecting this from the dropdown will provide you with the notification that is critical in nature, for example- stopping of the bot.

Verbose Control Notification: Selecting this from the dropdown will provide you with the notification on every step of the trading bot workflow, in addition to the critical notifications. For example, you will be notified every time the bot enters the position.

TIP: You can use control notifications to track your bot for a while before attaching the webhook as your notification preference.

You can select SMS or Email or both as the mode for receiving the control notifications.

Control notifications

Limitation: Bots check their criteria during weekends as well (one can see that in their verbose control notifications). It's a limitation of the MVP.

Bot Behavior Settings

The bot behavior settings allow you to configure how your bot should behave under certain circumstances. The set of settings you can customize depends on whether your bot has webhooks enabled or not (explained below).

Behavior Settings (When the Bot Has No Webhooks)

In this case, you can define the following two options:

I. When Missed A Check: This option is always selected to Notify & Stop a bot. If the trading bot has missed a check (for any weird reason, which is never supposed to happen), then you will be notified and the bot will be stopped.

II. When Started in Position: This option allows you to decide how the bot should behave if it starts while already being in an entry position, by making the selection between any of the following two from the dropdown.

  • Generate the first entry after the next exit: Selecting this will allow the bot to pretend as if the bot was never in the entry position. In this way, the bot will wait for the next exit and then wait for the next entry before going in.
  • Generate the entry signal immediately: Selecting this will allow the bot to make an entry position right away since the bot is already in an entry position.

Behavior Settings \(When the Bot Has No Webhooks\)

Behavior Settings (When the Bot Has Webhooks)

If your bot has webhooks attached, then the system allows for setting a few additional options. When there’s a webhook, you are provided with the option to handle the “webhook calls failures”. Webhook call error is not somewhat what’s supposed to happen, but eventually, your webhook provider might have issues and we want you to be in control of what the bot should do in this case.

In this context, a “failure” means “webhook has failed to respond within 7 seconds or has responded with an HTTP code which is 4xx or 5xx but not HTTP 400.

The additional options which are only available if your bot has webhooks attached are listed below.

I. Retry failed webhooks: This option selected to Never means that the trading bot will not make a retry if failed to call the webhook. However, selecting a particular number for the retry will allow the trading bot to perform the retry for the number of times selected with a pause of 3 seconds between the attempts. For example, selecting Retry 5 Times will enable calling webhook up to 5 times like that:

1. Call a webhook
2. Wait for its response (or for a time-out of 7 seconds)
3. If it’s worth retrying (according to the error code) then wait for 3 seconds
4. Repeat 1-3, up to 4 more times

II. When failed to enter: If the Bot fails to “enter the position” (defined as “calling a webhook failed after the set number of retry attempts defined in (I) above”), then you will need to define the behavior of the bot by making a selection between any of the following two from the dropdown.

  • Notify and assume manual entry: Selecting this option will send you a notification for the failed entry and instruct the bot to assume that the entry has happened and proceed to work as usual (which means that it will start seeking to exit the position, as per your strategy).
  • Notify and stop a bot: Selecting this option will send you a notification for the failed entry and instruct the bot to stop functioning.

III. When failed to exit: If the Bot fails to exit the position after the set number of retry attempts defined in (I) above, then you will need to define the behavior of the bot by making a selection between any of the following two from the dropdown.

  • Notify and assume manual exit: Selecting this option will send you a notification for the failed entry and instruct the bot to assume that the exit has happened and proceed to work as usual.
  • Notify and stop a bot: Selecting this option will send you a notification for the failed exit and instruct the bot to stop functioning.

NOTE: Failure to call a webhook (after all the attempts, if any) is a subject for a critical control notification, never mind what the “When failed to ***” settings are.

Behavior Settings \(When the Bot Has Webhooks\)

After configuring all the above settings, click on the CREATE BOT button. After that, the trading bot will start generating and painting the entry/exit signals according to the strategy defined. After creating the bot, it is added to the Trading Bot widget in the right sidebar.

NOTE: There are some corner cases when you have one candle generating both entry and exit signals (i.e., stop loss triggering and entry condition triggering at the same candle). In case your bot was “in position” before this candle, then it won’t generate any signals at all and will stay in position instead.

NOTE: Bots check their conditions as soon as the corresponding candle closes, in 40 to 60 seconds.

Click on Create Bot button

Creating a bot will clone and lock the particular strategy that has been used so that you can have a record of the strategy used and check it out at any time for your reference. You cannot edit this strategy and it will be in the read-only mode.

Creating a bot clone and lock the strategy

If you want to change the strategy, then you will have to perform the alterations in the original one and then create a new trading bot using it as a base. Also, you can not remove the “cloned version” of the strategy until there's a bot which uses it. Removing a bot removes its own clone of a strategy.

Note: Cloned strategies are named after the bot “as of the moment when you created it”. If you will rename a bot, then the cloned strategy won’t be renamed.

Limitation: Creating a bot disables the “ext.hours” flag for a strategy. Currently, trading bots can’t work on extended hours candles.

On-Chart Signal Marks

After creating the bot, it will generate the entry/exit signals and paint them on the chart using the strategy defined. A bot paint signals only when the chart matches it in terms of ticker, time frame, chart type, and extended session status. For example, you won’t see your 15 min bot’s signals on a Daily chart.

On-Chart Signal Marks

For a more clear view of the signals painted by the trading bot, you can choose to toggle off and hide the strategy tester from the indicator list on the top-left corner of the chart.

toggle off and hide the strategy tester

The entry/exit signals will stay visible on the chart as long as the bot is not removed and the Alerts & Bots button is toggled on (enabled) at the top toolbar.

Alerts & Bots button is toggled on

Limitations:

  • The colors are assigned automatically while creating the bot and you cannot customize them. It’s a limitation of the Beta version which will be resolved soon.
  • You cannot hide the marks generated and painted by one trading bot. You can only hide or display all the marks of all of your bots and alerts.
  • Trading Bots do not paint the execution arrows on the mobile view for now.

Verify Trading Bot Functionality

Trading bots internally make use of backtesting the strategy you have defined which means that you're guaranteed to have bots doing exactly what your strategy does (and proceeding acting according to how your strategy has acted when you backtested it).

However, if you want to compare, then please use the “cloned/read-only” version of a strategy, because it’s exactly the version your bot uses. This version of a strategy will have its “Backtest date” locked to a particular date in the past and this date won’t ever change.

To verify the trading bot functionality, you can use control notifications that explain your bot‘s behavior and track your bot for a while before attaching a webhook. In this way, you will have an understanding of how things work and what to expect.

Manage Trading Bots

You can manage your trading bots from the trading bot widget and perform the following actions:

  • Edit the Trading Bot Settings
  • Stop the Trading Bot
  • Clone the Trading Bot
  • View Trading Bot Status
  • Remove the Trading Bot

Edit the Trading Bot Settings

Edit any of the active bots from the list to execute the following modifications:

  • Bot Name
  • Notifications
  • Control Notifications
  • Some of the Behavior settings

Step 1: Click on the edit icon on any active trading bot from the list.

edit icon of active trading bot

Step 2: A modal window for editing the Trading Bot will appear, allowing you to execute the necessary modifications listed below.

1. Rename the Bot
2. Change the notification mode
3. Change the control notification preferences
4. Change those Behavior settings which are not locked (like “when failed to enter” for example)

modal window for editing the Trading Bot

Step 3: Click on the SAVE button after making the relevant changes.

Click on the SAVE button

Stop the Trading Bot

You can stop an actively running trading bot to stop receiving any signals. Please note that stopping a bot leaves your position “as they are”: a bot won’t attempt to exit the position if it exists.

Step 1: Click on the Stop icon of any of the active trading bots from the list.

 Stop icon of the active trading bots

Step 2: A confirmation window will appear. Click on the YES button to proceed with your action.

Confirmation Window

Clone the Trading Bot

When an existing Trading Bot is cloned, whether active or inactive, a complete copy of all the configurations is done (except the backtesting strategy) which you can use as a base for creating a new Trading Bot.

Step 1: Click on the Clone button of any of the active trading bots from the list.

Clone button of the trading bot

Step 2: A modal window for cloning the Trading Bot will appear, allowing you to create a new Trading Bot by using the existing configuration as a base.

modal window for cloning the Trading Bot

Step 3: You can choose to keep the existing configurations or edit the same for Name, Time Frame, Notification Mode, Control Notification Preferences, and Behavior Settings. Once done, then select the backtesting strategy from the dropdown, click on the Create Bot button, and the new Trading Bot will appear in the listing.

click on the Create Bot button

View Trading Bot Status

Click on the ⓘ button of any of the active or inactive trading bot from the list to view its current status.

View Trading Bot Status

A rectangular callout window will appear providing you with the following details:

  • Name of the Bot, Symbol, and Timeframe Selected
  • Backtesting Strategy Used
  • Date and Time of Creating the Bot
  • Date and Time of Updating the Bot
  • Running Status: Active or Not Active
  • Position Status: In Position or Not in Position
  • Last 5 signals (if they exist): action + date & time for each of them

rectangular window providing the trading bot details

If checking the status of an inactive Trading Bot, then in addition to the above details (except Signals), you will also view the Date and Time of Stopping the Bot and the Reason for Stop.

Date and Time of Stopping the Bot

Tip: You can also copy and paste the Trading Bot status information.

Remove the Trading Bot

You can permanently remove a stopped trading bot from the list by clicking on the delete icon button. Removing a trading bot will leave your positions “as they are” (it won’t exit if it’s in the position) and will wipe all the bot’s action history from our servers. You will stop receiving any signals from this bot and you won’t be able to undo this action.

Remove the Trading Bot

A confirmation window will appear. Click on the YES button to proceed with your action.

confirmation window

Changing or Downgrading Plan

If you will select a plan in which backtesting is not available or downgrade your plan (which either has less of bots or does not allow for backtesting), then all of your bots will be stopped.

Best Practices

Follow the below-listed practices for the best results:

1. In general, we recommend taking the following steps before you have your bot trading with real money:

  • Backtest your strategy and make sure that it’s sane
  • Run it as a bot, but don’t attach it with any trading webhooks: enable verbose control notifications and wait for a couple of days to make sure that its behavior does match your expectations.
  • Attach entry/exit webhooks that trade. You’re ready now!

2. Don't trade manually with the assets (tickers) managed by your bot, unless you’re correcting its mistakes

3. If you trade cryptos, then do have some spare amount of a currency for the purpose of paying the fees, or trade using “percentage of your account” rather than “amount of currency”.

Frequently asked questions

Q 1: My bot had been stopped by the system as "it can't be trusted any more". Why?
A: Things like that are not supposed to happen in normal circumstances, yet still they can. Long story short, upon every check bot checks quite a few things in order to make sure that it's reliable and launching on time e.t.c. We call that a "health check" internally. Sometimes this check reveals problems, which means that this bot is at risk of being inconsistent with its signals. In the vast majority of cases, it means that there's something wrong on our end. We're being notified about every case when a bot fails and we treat these with the highest priority. We're aiming for making that never happen as Beta comes to an end.

Q 2: My webhook was not executed, why?
A: When you create a bot, please have Verbose Control Notifications (via email) enabled for a while. Any time bot enters or exits, it will send you an email about that along with a copy of your webhook server response. Please verify that the response is legit and is not flagging any errors in the input data (i.e., in your JSON). If your webhook service is not stable, then please consider enabling "Retry failed webhooks".

Jun 22, 2022

Contact Us

Not finding what you're looking for? Contact Us Directly