All you need for a mechanical trading system

jameshall9

Newbie
Messages
5
Likes
0
I've read lots and lots now about the psychological aspects of trading and ideas surrounding theoretical system design including, entries, exits, position sizing etc.

I now want to put some of this into practice and develop a system. I was hoping for some advice and pointers on software etc that will be needed. Any critique or suggestions about the following thoughts would be greatly appreciated. As I see it there are 3 stages which I need to think about: a back testing system, an entry and exit system and then finally a system actuator which places the trades.

Stage 1 Back testing

I think I need the following and would welcome suggestions of what software to use or where to get the data from: Historical prices (I want to be able to go back about 100 years), Data manipulation software for testing any system against historical prices - I was thinking Matlab maybe the best option for this as it has some very good charting tools and matrix manipulation tools. Does anyone else use Matlab? If so what are its advantages/disadvantages? Would you suggest using anything else, if so why?

Stage 2 The system
Again I was thinking of using Matlab for this as I know it can cope with a live input of data and create a live output. In respect of getting live quotes where would you suggest getting these from? Do people usually get these prices from the same place as they place their trades? I've not yet decided exactly what markets I want to trade but likely a combination of FX and commodity futures. Do most data providers have a API which can link with Matlab?

Stage 3 The actuator
You guessed it Matlab. - I suppose a lot of my questions for the previous section apply here.

As i say any advice on the practicalities of all this would be much appreciated. I have my own idea of how to get it all working but avoiding pitfalls others have made is always helpful.

Thanks in advance for any responses.

James
 
The first thing you need is a robust system that you understand very well. Only then can you go to the stage of developing an auto system.

Many people seem to be under the impression that if they go down the automated route and make the emotions disappear, they will become profitable. There is a reason why the emotions exist in manual trading, it is not knowing what is going on.

If you have no control of the manual system, how and what parameters would be programmed to avoid the same mistakes ?
 
The first thing you need is a robust system that you understand very well. Only then can you go to the stage of developing an auto system.

Many people seem to be under the impression that if they go down the automated route and make the emotions disappear, they will become profitable. There is a reason why the emotions exist in manual trading, it is not knowing what is going on.

If you have no control of the manual system, how and what parameters would be programmed to avoid the same mistakes ?

So you're suggesting that initially one should run a system manually to get a better feel for its quirks and faults as only then will you be able to develop it to the required level of performance? I guess that makes sense. Do you not feel it would be possible to review a fully automated system and see where it can be improved?

Thanks
 
I've read lots and lots now about the psychological aspects of trading and ideas surrounding theoretical system design including, entries, exits, position sizing etc.

I now want to put some of this into practice and develop a system. I was hoping for some advice and pointers on software etc that will be needed. Any critique or suggestions about the following thoughts would be greatly appreciated. As I see it there are 3 stages which I need to think about: a back testing system, an entry and exit system and then finally a system actuator which places the trades.

Stage 1 Back testing

I think I need the following and would welcome suggestions of what software to use or where to get the data from: Historical prices (I want to be able to go back about 100 years), Data manipulation software for testing any system against historical prices - I was thinking Matlab maybe the best option for this as it has some very good charting tools and matrix manipulation tools. Does anyone else use Matlab? If so what are its advantages/disadvantages? Would you suggest using anything else, if so why?
I can't comment directly on Matlab, having never used it. Other possibilities are Amibroker (cheap one/off cost for a programming language and tools already setup for trading) or Tradestation Easylanguage (more expensive option, but again setup specifically for trading).

I would question how relevant it would be to go back 100 years. Markets change their nature over time, especially that amount of time, and particularly more recently with the use of algorithmic trading.

There are also issues with following individual equities over that kind of time period bearing in mind changes in the nature of companies, mergers, rights issues etc etc

Stage 2 The system
Again I was thinking of using Matlab for this as I know it can cope with a live input of data and create a live output. In respect of getting live quotes where would you suggest getting these from? Do people usually get these prices from the same place as they place their trades? I've not yet decided exactly what markets I want to trade but likely a combination of FX and commodity futures. Do most data providers have a API which can link with Matlab?
If you are going to go down the Matlab route I would suggest that you search for free code that you can build into trading modules. Google matlab trading. For example the following link provides code from one developer to make use of the API from IB. IB also has an API with Amibroker.

Matlab Trader - InteractiveBrokers

IB and Tradestation have their own data. Esignal is also a popular choice. If you are getting the datafeed from the same place as where you place orders then you will probably simplify things in terms of syntax and understanding how a particular broker's APIs work. This is why, of course, using the programming language, data feed and brokerage services from one single provider is the simplest solution.


Stage 3 The actuator
You guessed it Matlab. - I suppose a lot of my questions for the previous section apply here.

As i say any advice on the practicalities of all this would be much appreciated. I have my own idea of how to get it all working but avoiding pitfalls others have made is always helpful.

Thanks in advance for any responses.

James

The actuator would be the broker's API which will accept input in a pre-defined format, so I would say that Matlab would provide stages 1 and 2 sending a file via the brokers API as stage 3.

Whichever route you decide the best thing is to search for specific forums on your chosen programming language, broker and API. A lot of the "standard modules" e.g. creating a buy order, stop-order etc will have probably been written before, leaving you to concentrate on the strategic parts e.g. entry, exit, calculation of position size

Charlton
 
I can't comment directly on Matlab, having never used it. Other possibilities are Amibroker (cheap one/off cost for a programming language and tools already setup for trading) or Tradestation Easylanguage (more expensive option, but again setup specifically for trading).

I would question how relevant it would be to go back 100 years. Markets change their nature over time, especially that amount of time, and particularly more recently with the use of algorithmic trading.

There are also issues with following individual equities over that kind of time period bearing in mind changes in the nature of companies, mergers, rights issues etc etc


If you are going to go down the Matlab route I would suggest that you search for free code that you can build into trading modules. Google matlab trading. For example the following link provides code from one developer to make use of the API from IB. IB also has an API with Amibroker.

Matlab Trader - InteractiveBrokers

IB and Tradestation have their own data. Esignal is also a popular choice. If you are getting the datafeed from the same place as where you place orders then you will probably simplify things in terms of syntax and understanding how a particular broker's APIs work. This is why, of course, using the programming language, data feed and brokerage services from one single provider is the simplest solution.




The actuator would be the broker's API which will accept input in a pre-defined format, so I would say that Matlab would provide stages 1 and 2 sending a file via the brokers API as stage 3.

Whichever route you decide the best thing is to search for specific forums on your chosen programming language, broker and API. A lot of the "standard modules" e.g. creating a buy order, stop-order etc will have probably been written before, leaving you to concentrate on the strategic parts e.g. entry, exit, calculation of position size

Charlton

That's a really helpful starting point thanks. I understand your query regarding 100 years. This is something I will consider when testing my system but I want to have the option should I need it.
 
So you're suggesting that initially one should run a system manually to get a better feel for its quirks and faults as only then will you be able to develop it to the required level of performance? I guess that makes sense. Do you not feel it would be possible to review a fully automated system and see where it can be improved?

Thanks

It all depends on what your goals are. Before you even begin you have to have a level of performance you would like to acheive. The end result i assume would be the same for al programmers, to have a successful system that runs without intervention. However to reach higher level of performance you will have to have an understanding of how to get there and what factors are involved.

The idea behind this approach is saving time and building confidence in your system faster. You know what works and how it comes about, so you program what you know, you will then be in a position to identify if your outcome matches what you believed you had programmed. Using the other approach the problem maybe that you dont really have a benchmark for comparison. This way you may end up writing many approaches without being in a position to understand what to change and why to change it.

It all depends on what you are aiming for. You have to know how to get to the desired level of performance and what factors are invololved in attaining that.
 
Last edited:
James,

Software for testing: You are best to do your own testing. That way, you will know exactly how the results are being calculated. Also, as this will inevitably take longer than using prepackage software, so you will gain a more intimate understanding of your trading rules and how they perform. This may sound like a disadvantage, but not rushing to the first trade usually allows you to catch an error, or make further improvements.

If you dont know anything about programming....you know have a good reason to learn. I didnt know anything about programming when I ran my simulations, so I used excel. It is slow and cumbersome, but it gets the job done. As for 100 years of data......surely 50 will be enough.....even in the last 25 years, you have had enough "events" like 9/11, Oct 1987, NASDAQ bubble, LTCM, Russian Bond Default, Agentinian Crisis, Sterling ERM Crisis, Asian Crisis....etc, etc.

Psychological Aspects: You can read all the books you like.....until you are in a 30% drawdown and have to take a trade that you gut/head says will fail, you wont know anything about the emotional aspect of trading. If you fail to take that trade at the bottom of the 30% drawdown, and it turns out to be a huge winner....you will have just learnt a lot about the emotional/psychological aspects.

The hardest (and most underrated) part of trading a set of rigid rules, is following them when they dont feel right. Anyone can design some entry/exit rules that make money, with a little thought, you can improve the performance with some intelligent risk management, but after that, all that is left to do is the trade the rules....this is the hard part.

I believe that if you have a deep and intimate understanding of your risk profile, it is much easier to stick to your rules. If you are aware that the 20+% drawdown comes along 5 times every 7 years, that drawdown doesnt leave you questioning your system. If you do all your own research, from the ground up, you will have a much better understanding of your risk. You can run your own analysis of whatever aspects of the performance are important to you, rather than those that are important to a software developer.

Best of luck with your trading.

AP
 
if you cant trade consistently profitably on manual execution, then telling a computer how to trade will not make any difference at all.

be honest with yourself, if you are not consistently profitable on manuel you are going to be wasting your time.
 
Top