Nicolas Darvas penned a book called How I Made $2,000,000 in the Stock Market. It is a record of the method he invented to select and trade stocks. The recent reprint includes an Appendix where he has a question and answer session explaining in further detail how his system works. His basic selection criteria is based upon stocks that have hit their 52 week highs. He then has a four day entry criteria backed up with a customized exit criteria. As you are probably aware, any time you always want to know what you risk is going to be. With the built in exit criteria, all the bases are covered. The exit condition is refined as the position changes in price. In the 2005 May issue of Technical Analysis of Stocks & Commodities Magazine, Daryl Guppy wrote an informative article discussing the technical implementation of the process. For the SmartQuant QuantDeveloper environment, I've written a C# class called Darvas that implements the method as described in that magazine article. The code, as supplied in the attached file, as some of the indicator code commented out. You can uncomment if you wish to use it as an indicator. The core of the code accepts OHLC Bars as input, which should be Daily bars from a simulation run, and generates Buy and Exit signals along with a Stop level. The code is straight-forward enough to be ported to other environments as well. |
Monday, November 27. 2006
Darvas Trading Module
Thursday, November 9. 2006
Fast Trading Simulation Engine
Are you running complicated trading scenarios incorporating equity and option mixtures from a quote/depth data stream? Are you using Genetic Programming tuned Fuzzy Logic algorithms? Are your sims taking a while? I think you may get a boost soon, if not real soon.
Intel is about to release their new quad processor, known as the QX6700. It is a dual die Conroe Dual Core CPU. Continue reading "Fast Trading Simulation Engine" »
Thursday, November 2. 2006
Fuzzy Logic
For an Automated Trading system I've been developing, I've come across the fact that Fuzzy Logic may assist in making decisions on how to trade at particular times of the day depending upon what conditions are predominant. Amazon has a bunch of theoretical books, but hardly any at all for the practical practitioner. I did purchase The Fuzzy Systems Handbook, 2nd Ed by Earl Cox. I'm about half way through it now. I've got through all the bits that make up the basic fuzzy sets. The sections are liberally sprinkled with C++ code. I'm not sure how much of it will compile in today's tools. The book was written back in the age of Windows 98. On the other hand, the code snippets are readable for one needs to understand what is happening in the commentary. |
I had approached the subject from a different perspective though. I started by searching for code libraries. I came across FLUtE: Fuzzy Logic Ultimate Engine. The fellow has written a code library in C#. The code does compile in Microsoft Visual Studio with the v2.0 run time libraries. Coding new stuff in it may be somewhat of a challenge as the documentation is quite sparse. But then again, that is par for the course.
After taking a look at the modules, I came across something called 'hedging'. At the time, I didn't know what it was all about. And that prompted me to look for some good practioner's books. Hence the book I referenced above. Hedging, is obvious once you think about it. It is adding fuzziness to an existing fuzzy rule. The concept is well described in the book. The book doesn't exactly flow from front to back. For instance, during the beginning of the book, the author introduces a concept called alpha-cuts, and incorporates its use in to the development and discussion of fuzzy rules.. I can see what they do, but where and how they are applied, I'm still not exactly certain. And I'm up to page 344 now. There have been some hints, but no concrete usage criteria. I'm sure it will become clear as I move along in the book. |
It was good that I did some prior reading, otherwise I think I would have been lost with the onslaught of information. I recall one of the first things I read was the document regarding the Mathworks Fuzzy Logic Toolbox. You can review the document in html or as a complete pdf document. In the pdf version, on page 56 (2-26), they have an excellent drawing summarizing how everything fits together.
Another book that helped fill in the gaps is An Introduction to Fuzzy Logic For Practical Applications by Kuzuo Tanaka. It is quite expensive for its 138 pages, but does have some useful background info. In the end, it is a good pocket guide for starters. It did leave me thinking that there were holes in the information presented. Earl Cox's book has filled in some of those gaps.
Having said all that, I'm just beginning to build the environment for using fuzzy logic in my trading solution. Although the FLUtE code looks like it could work, I'm going to try my hand at some basic C# code for fuzzy rules and rulesets to get a feel for what is needed. Once that is in place, I think I can then use a Genetic Programming engine I wrote to see if I can optimize some rule selections.