Automated Trading Systems 9


Some Very Important Details When Constructing Your Own Fully Automated Trading Systems

The following article was taken from an exchange of emails with several clients. I felt this part of the dialog would be very helpful for our viewers. included below are some of the most important aspects to be aware of when constructing fully Automated Trading Systems.

There is no “Set it and forget it”

It’s important that you understand that an automated trading system should NEVER be left unattended. Many **events can take place while the system is running that require human intervention.
So please evaluate this first of all. You will need to be present while the system is placing trades on your account. If you had planned on having the system trade while you are sleeping, or away at work…. STOP NOW. Do not proceed any further with your plans.

 

Trading System Platform Selection

The second most important detail. Thinkorswim is not fit for this purpose. You will need to use a platform that supports automated trading systems. Such as TradeStation, Sierra Chart, Interactive Brokers, eSingal, NinjaTrader, or amibroker (not a complete list).

Stock Options and/or Options on Futures

At this time I am not aware of any platform available to retail traders that can select and trade any options contracts based on the signals generated in the underlying stock or futures contract. Commercial platforms do exist for this purpose. Expect to pay a great deal of money for access to any platform that does support automated trading of options contracts.
Edit: In response to this section on options a client has asked for clarification. Included here is the dialog from that email:
 Does it mean the code you write is not expected to work for stock options?
Let’s take the TradeStation platform as our use-case.
The automated trading system will run based on an open chart on the platform. Whatever ticker symbol is loaded onto the chart, that is the symbol the system will trade. So if we chart the symbol of AAPL, the system will buy and sell shares of AAPL. It will NOT be able to buy and sell options on AAPL. If you wanted the system to trade a single option contract, the OPRA code of that single option would need to be used as the ticker symbol for the chart. The chart would then display trading activity for that specific option contract. Any buy/sell signals generated on that chart would then be used to buy and sell that specific option contract. Therefore, an automated trading system on TradeStation will NOT be able to chart AAPL and then pick and choose from a list of options contracts and expirations to trade.
**events which will require human intervention (not a complete list):
  1. Computer experiences loss of power and/or an interruption in its connection to the internet
  2. Computer crashes while the system is running
  3. The broker rejects an order
  4. The broker suspends or otherwise interrupts the data fee
  5. The exchange suspends trading in the selected financial instrument

 

User Intervention for Automated Trading Systems

If at any time during the course of normal operation any of these **events occur. You will need to be prepared to do the following (not a complete list):
  1. Shut down the automated trading system to prevent new orders being generated
  2. Cancel all open orders
  3. Flatten all existing positions
  4. Restart the trading system once you have a clear slate

Backtesting and Walk-Forward Analysis

Perhaps the greatest use of any automated trading system is the ability to perform a proper backtest of the strategy. Following the backtesting phase, the second most useful aspect of an automated trading system is to perform the walk-forward analysis.
This is where you find out if profits generated during the backtest on historical data is reproducible when trading a live market. Walk-forward analysis is done by running the automated trading system on a simulated trading account during live market hours. (NOT on a live “real money” account).

Automated Trading Systems: Never a simple process

Writing the code for any automated trading system is never a simple process. It is similar to writing a chart study, but there are many additional items that need to be accounted for.
Just one example, the code must account for slippage, when stop or market orders are used for entries and/or exits. Trailing stops can be challenging depending on how complex the exit rules are. Profit targets also present a challenge, especially if they are based on the entry price.

 

Conclusion

Automated Trading Systems can be a very useful tool for traders that are already profitable in their trading. It is dangerous to think that an automated trading system will make you profitable when you haven’t arrived at that point already. They can do far more damage than trading manually, so focus on being profitable first. Before getting started, you should carefully evaluate whether you can increase your current profitability through the use of an automated trading system. Remember that an automated trading system still requires that you be present, in front of the computer. Because at some point the excrement will hit the proverbial fan, this WILL eventually happen. So you must be there to pick up the pieces and reset everything to a clean slate before turning the system on again.

Recommended for further study

Thinkorswim Strategies Complex Stop Management

Strategies Winning Percent Versus Risk Reward

TradeStation Strategy Guide

 


About Pete Hahn

For those trying to contact me about our professional services you will find all those details here: https://www.hahn-tech.com/about/ Any questions not related to our professional services or premium indicators should be directed to the comment section of the applicable video or you may post a question in our Q&A Forum: https://www.hahn-tech.com/thinkorswim-forum-topics/

Questions? Comments? Post a review?

9 thoughts on “Automated Trading Systems

  • Dan Haynes

    Hi Pete. I created a conditional exit script that exits and entry based on a very similar entry script. The entry triggers when the condition is true and exits when it is false. The problem I’m seeing is most times it works as planned but sometimes the exit triggers as soon as the entry triggers. Unsure why or how but seems Thinkorswim sees it as true and false at the same time. Even more confusing is I set this script in 2 different accounts and one day it triggered in both accounts and one account behaved as planned but the other account sold instantly. I can provide the script and conditions but unsure if you want me to paste them in here

      • Dan

        That was kind of my thoughts too. I have been digging through and can’t figure out why it triggers both true and false occasionally but did look after watching your most recent video and my script has 71 lines of code so that may be the issue? I’m going to look into a different exit strategy to implement then backtest it. Thanks!

      • Pete Hahn Post author

        Ok, good luck to you. Be sure to check if your code uses recursive variables, as I demonstrated in my most recent video.

  • Frank

    Does TOS allow an advanced order at a pre-set time, such as 30 minutes before or after an event? If yes, how to write a code? Event trading such as earnings day, FOMC meeting, etc. may need a “time-triggered” order.

  • Sam Faruki

    I need help setting up a Thinkscript Scan in TOS for the following conditions:

    High High for 40 days Low Low for 40 days

    TOS people refused to help.
    Please let me know how much it will cost.
    Thanks
    Sam Faruki

    • Pete Hahn Post author

      1. We do provide professional services and those details are explained on the following page of our site: https://www.hahn-tech.com/about/
      2. You will find that we do not provide price quotes or estimates.
      3. You will need to provide more details if/when you fill out that contact form at the bottom of the page to submit your custom project request.