Testing Matlab-IBTWS Algo-Trading on Stocks

Following on my last article on Testing Algo-Trading, today I will share with you my results in implementing the simple Trend Following Strategy on Stocks. The trades and all the data are as of today 4th of March 2016 (CET).  I have randomly chosen Apple Inc. (ticker AAPL)* as a US stock example and I had Matlab run the code on 1 minute candles almost the whole regular trading session from 16:00 CET till 22:00 CET in the evening. The result is even better than expected. Despite a very simple strategy ever known, it made a profit on stocks as well. Actually most of the time, the strategy bought lower and sold higher. A global overview can be observed on the chart below:

Stock Algo-Trader Chart

This time the algo jumped in a bull market and went long 1’000 AAPL shares from the very beginning. The invested quantity is always the same. If there is a cross of the short SMA above the long SMA, the computer buys 1’000 AAPL shares, if the short SMA goes under the long SMA, the algorithm sells 1’000 AAPL shares. With Interactive Brokers, the leverage one can use intra-day on US stocks is 4/1, so during the day, in a margin account, the requested initial and maintenance margins are of only 25% of the exposure. That meaning, in order to trade 1’000 AAPL shares trading at around USD 100/share, one needs only USD 25’000 to trade them during the day. After the trading session, I found the following summary in my trade log:

Stock Algo-Trader TradeLog

Actually, once again, the strategy, most of the time bought lower and sold higher. Putting all of the above in an excel file, today, on 1’000 AAPL shares my PC made a profit of USD 1’152.06.

Stock Algo-Trader Profit

A profit of USD 1’152.06 in a cash account, means a daily return of around 1.1%. In a margin account this is well around 4.5%, which for me, on stocks, is simply amazing.

Again, this is just another example and it can be the hazard, however it worked. I will keep testing and post my results regularly. Of course the strategy will be provided with a long-term back-test as well. Feel free to ask questions, share your experience and comment. Once I will consider this strategy fully tested, I will build a simple graphic interface program, with buttons and configurable fields, that will allow any of you to install it and test it on your own. By then, thank you for reading me!

* The tickers shown in examples are random, for exercising purposes only and do not represent any advise to invest in them nor any other kind of advertising.

Leave a Reply

Your email address will not be published. Required fields are marked *