About this template
This sample bot template explores a potential framework to use for trading short-term, directional long debit spreads using a popular EMA crossover signal. The bot focuses on scanning for EMA crossovers, default settings use 5-day EMA crossing above/below the 9-day EMA, to enter an ATM long call/put debit spread. Plus, we've used custom inputs to help control and customize the bot's actions as well as another fun little "Switch" to allow the bot to have control over exiting on EMA signal reversals if you choose.
The template only requires one scanner automation. This scanner quickly loops through your tickers and does a quick couple of checks to make sure that you don't have any existing positions in that symbol and that the bot has the ability to open a new position. Next, the scanner evaluates the 2X EMA signals for each symbol in your list.
IF the shorter EMA crosses ABOVE the longer EMA, the bot will look to open a Long Call (Debit) Spread.
IF the shorter EMA crosses BELOW the longer EMA, the bot will look to open a Long Put (Debit) Spread.
The goal is to directionally trade with the market’s short-term momentum with risk-defined spreads. Here's an example of the types of signals this would generate in both directions in the last ~6 months using SPY.
New positions are set up to look for spreads approx. $5.00 wide that are as balanced risk/reward wise as possible around the current underlying price. The bot looks for the long leg to be $2.50 ITM and the short leg to be $2.50 OTM, or as close as possible.
Before any positions are opened, the bot checks the bot's available capital and the probability of a profit is over 50% before sending the order to your broker. If the target opportunity does not meet the liquidity and probability requirements, then the scanner ends and rechecks again at the next interval.
Note: We've also used Position Tags to tag opened positions as ‘short duration,’ which might help you organize your positions if you're trading spreads across other bots. With tags, you can sort and filter positions by tag so you can see which positions were entered under what conditions.
For this particular bot sample, we are using two monitor automations. Though they are very similar to one another, each is set up specifically to manage either Long Call Spreads or Long Put Spreads respectively. This gives you more control if you wanted to adjust how one type of position is managed in your version of the bot. As always, this is just one of a million ways to use bots and automations but we always want to give you more ideas to spark creativity.
Within each monitor automation, we're first checking for the specific position type to reach our profit target. Next, we’ll see if the position is now inside our expiration threshold, and close the position if so. Finally, we encounter a "Switch" for allowing the bot to exit positions IF the 2X EMA signal used to enter the trade reverses. Since this switch is controllable, you can choose to allow the bot to exit on reversals or not, simply by turning the switch ON or OFF inside the bot settings.
The default setting for this strategy is to leave the switch ON and allow the bot to monitor the 2X EMA signal for reversals. If the bot gets a reversal, then it would close that particular position.
Note: Again, we used Position tags inside our monitor automation to tag closed positions based on the conditions in which they were closed so you can see how/why the bot closed the position later on when reviewing your trades.
You’ll notice on this bot sample that we’ve added bot-level inputs for all parts of the strategy that are controllable. This works really well with this strategy because it gives you the power to connect different automation inputs together in one place.
In particular, this strategy relies on 2 EMA lengths for entry and exit signals. The scanner uses the EMA signals for entry and each of the monitor automations uses the EMA signals for exits. By adding bot-level inputs for these EMA lengths, ALL our automations can reference one set of inputs to be used throughout the bot. This makes the bot not only easy to edit and modify, but also insanely powerful and interconnected.
Want to learn more about creating and using bot-level inputs? Watch this video: https://optionalpha.com/help/bot-level-inputs
These sample templates are just a starting point for bot building. Post your own modified/edited version(s) of this bot template in the comments below or publicly in the Community to help crowdsource new ideas for your fellow traders.