This bot example video demonstrates how to create a simple trend trading bot for stocks using a scanner and monitor automation to automate trade entry and position management.
The bot’s objective is to buy a stock when the security is above a long-term moving average and subsequently sell the stock when it drops below the moving average. The bot uses one scanner automation to open a position and one monitor automation to manage the position.
Create a Bot (:34)
To create a new bot, select “Create Bot” from the Bots homepage.
You can name the bot, choose a custom icon, and set allocation and position limits in the bot’s global settings. When you are finished, select “Create.”
The bot dashboard displays all the bot’s information, including the bot’s performance, activity, settings, and account type. You can access the Positions tab, Automations tab, and Log from the dashboard. The bot is turned off by default, and you must turn it on when you are ready.
Add a Scanner Automation (3:27)
Select the “Automations” tab to display the different automation types.
To create a new scanner automation, select the “+” icon in the Scanners section.
Scanner automations run on defined time intervals and look for opportunities to enter new positions based on the decision recipes you create.
Select “New Automation” to create a new scanner automation for the bot. You can create a new automation or choose an automation from your library.
Add a Decision Action (4:16)
In the automation editor you can name the automation and add bot actions.
To add a decision action to the automation, select the “+” icon.
Decision actions are typically used at the beginning of a scanner automation so the bot can filter through specific market data before entering a position.
There are multiple criteria to choose from when using decision actions. For this example, the bot will use a recipe to check the moving average relative to the underlying stock’s price.
Manually enter inputs in the variable fields to tell the bot precisely what data to reference as it moves through the automation:
- Above / below
- Time period
- Moving average indicator
When the criteria are in place, select “Save.” The decision action is added to the automation editor. The automation will follow the “Yes” path if SPY is above the 200-day SMA.
Open a New Position (6:47)
To open a new position if the underlying ticker symbol is above the 200-day SMA, select the “+” icon under the “Yes” branch of the automation editor. Select “Open Position” from the available bot actions.
There are multiple position types available. This bot will open a long equity position.
You can select the symbol and amount of shares to trade.
You have multiple options when selecting the amount of equity to purchase.
Select “Save,” and the open position action is added to the automation editor.
If the ticker symbol’s price is above the 200-day simple moving average, the bot will open a long equity position with one share of stock. If the price is below the 200-day simple moving average, no position is entered, and the automation ends.
The scanner automation is now complete. Select “X” in the top right corner to exit the automation editor. Select “Save” to add the automation to the bot.
Remember, the bot is not active until you turn it on. Automations can be turned on or off at any time. Once the bot is on, the automations will run at their designated intervals. Scanner automations remain active unless there is not room to add new positions. Monitor automations automatically turn on when a position is opened inside the bot.
Add a Monitor Automation (9:13)
With the scanner complete, the bot will search for new long stock positions to enter based on the criteria. A monitor automation can be created to manage existing positions once they are opened. Monitor automations only trigger when a position is active inside the bot.
Monitor automations are created much like scanner automations. Select the “+” icon in the Monitors section to create a new automation or choose from a list of available automations in your library.
Select “New Automation” to create a new monitor automation for the bot. You can name the automation and save it to your library.
Repeater Action (10:46)
Monitor automations typically begin with a repeater action. Repeater actions pull information for a specified position type and loop through all corresponding positions open inside the bot.
To add a repeater action to the automation, select the “+” icon and choose “Repeater.”
You can select a position type for the repeater action to monitor, or it can monitor any open position.
The automation will loop through any long equity position the bot has open, regardless of the ticker symbol. The repeater action makes it incredibly efficient to manage multiple positions.
Add a Decision Action (11:50)
The exit criteria for the bot is determined by the underlying symbol’s 200-day SMA. To add a decision action that references moving average, select the “+” icon under the repeater action.
As with the scanner automation, select the recipe to check the moving average relative to the underlying stock’s price. Because the repeater action begins the automation, the bot will reference each long equity position.
You can easily link the same symbol used in the scanner automation with a custom input.
The custom input enables you to reference any position currently open, making the bot very flexible if multiple ticker’s are used.
Every time the monitor runs, it will repeat through every position type and ticker symbol it was assigned and check to see if the symbol’s price is below the 200-day simple moving average.
Close Position (13:40)
To close the position if the underlying ticker symbol is below the 200-day SMA, select the “+” icon under the “Yes” branch of the automation editor. Select “Close Position” from the available bot actions.
Use a custom input to close any long equity position that meets the decision criteria.
Select “Save” and the close position action is added to the automation. The bot will close any open long equity position that is below its 200-day SMA.
Select the “X” button and save the automation. The bot has a scanner automation to search for new positions to enter and a monitor automation to manage open positions.
Bot Log and Positions Tab (15:43)
Once the bot is turned on, the log displays automation activity.
Selecting an automation displays the automation’s activity. The automation’s actions are listed, including the decision’s results and position details.
Because SPY was above the 200-day SMA, a long equity position was opened at a price of $406.81.
The new position is displayed in the Positions tab.
Once a position is open, the monitor automation manages open positions. Because the bot has reached its daily position limit, the scanner automation automatically stops looking for new positions until there is room in the bot to add another position. The monitor automation runs at its scheduled interval.
The monitor automation will close the position if it is below the 200-day SMA.
You can always edit the bot’s global settings to allow for more positions. You can also manually close a position in the Positions tab. Simply choose the position you want to close and select “Close Position.”