Matlab for Backtesting

briant57

Newbie
Messages
3
Likes
0
Hi All,

I have been building mechanical trading models in excel for a time now, but have decided that i need to move on to something more powerful for future models.
The attached spreadsheet is a small example of how I have typically built models. Trade signals are shown as a 1, generated by various methods not shown. A trailing stop handles the exit.
Has anyone built a model in Matlab similar to this, or has seen something on the net where I could gain some insight to cut down on my learning curve?
I want to use matlab for its optimisation abilities, but my biggest problem has been how to get the trade entries/exits/PnL to work.

Thanks,

Brian
 

Attachments

  • example.xls
    56.5 KB · Views: 2,021
Haven't done anything similar, but there are some excellent webinars on the Mathworks site.
 
Haven't done anything similar, but there are some excellent webinars on the Mathworks site.

Thanks Gecko,

I have viewed the webinars, but it deals more with the optimisation once the framework is set up. I have been able to import my data and generate entry/exit signals, but am having trouble with calculating the profit of trades. Has anyone has experience with this before?

BTH
 
Brian

You could have a sift around on this blog Quantitative Trading as the guy uses Matlab for his quantitative strategies. I have just bought his book which has some examples of Matlab coding, mainly for strategy back-testing, however I really couldn't recommend it yet as I haven't finished reading it. Perhaps have a browse at your local B&N.

Sorry, not too much help!
 
I have used Matlab for these things, but it's not exactly a hard real-time system, so I have never used to generate real-time signals.
 
Have you tried the internal optimiser in Excel? I believe Excel also has other optimisers available as addons which implment GA etc.... So why rock the boat if this is the only reason.

On the other hand if you want to use the advanced modelling capabilities of Matlab where you are only limited by your imagination then that is another matter. I dont see why you couldnt implement your requirements in Matlab. There are also packages available for Matlab to link into IB and tradestation so dont let the trade execution aspects stop you. Also note that Matlab is quite expensive (with toolboxes as extra) so take this into account in your decision.
Cheers,
Imran
 
Hi Brian,

I can help you up if you give more details on what you've done in Matlab. I'm working myself in implementing strategies and backtesting in Matlab, but we haven't finished yet.

Best,

Paul
 
I know this thread is a bit stale, but the free software you get with IG Index (IT Finance) is excellent for all types of testing and optimizing, and the code doesn't take too long to work out. Metastock Pro is also good but I've found it a little flaky in places and a few bugs in there. I've considered learning MatLab but feel as though I can do most of what I want on the pre-made software.
 
What free software do you get with IG? I have been a customer for well over a year now and not noticed it at all? have a link or heads up on where on the site it is? cheers.
 
Matlab is a good tool for quantitative analysis :cool:, especially when you have big volume historical prices (e.g. ticks).
What can you do in Excel - just 65,000 points:whistling
 
Hi, I am new to this forum and i am also new in using mathlab... so anybody has any books recommendation for a beginner to start learning Mathlab in backtesting??
 
I looked at Matlab but it's too generic and broad. Instead, I switched to Amibroker, which I think is one of the best software packages out there. The advantage it offers over most other setups is that it can do portfolio analysis... it's also incredibly quick (mindblowing sometimes) and less than £300. You'll need to invest a couple of months learning how to code, but it's well worth it. (I have no affiliation to this company, fyg)
 
I adapted the following and now use this for backtesting:
http://www.modulusfe.com/tasdk/dotnet.asp

I hooked this up to a DB and built a backtesting engine on top of this. Now I can run over 7000 stocks dating back to over 60 years or so (approx 20 million data points total) in approx 10 mins.
 
Top