In an earlier post, I ranted about how I hate wealth-lab, and asked for input comparing it with Block, and or other options for back testing, custom indicator creation, custom indexing, etc... Well, I've been working with wealth-lab some more, and now....I REALLY HATE WEALTH LAB!.
I'm writing a script to back test the Darvas Box strategy. The strategy is explained in How I Made $2,000,000 In The Stock Market , by Nick Darvas.At a high level, we can say that the algorithm for generating buy and sell signals is a state machine with 5 discreet states. If you search online for the algorithm, this is the common description. However, the transition rules for each state have two symmetric sub-states (reverse the order of evaluation, depending on the direction of the prior box break-out, if you're last breakout was up, you evaluate the states looking for a range high first, if last break-out was down, you evaluate for a range low first).
So, to a human, the strategy can be described with 5 states, but for automated back testing, it takes 10 states. But there's more. Remember that we use the previous box break-out to determine if we calculate for high-first or low-first. But at the beginning of the price series you're testing against, there is no prior break-out, so there is a special case where we don't know whether to look first for a range high or low. So, it's an FSA with 11 discreet states.
As an object oriented programmer, my natural inclination when faced with this challenge is to implement the State design pattern. The Wealth Script manual says that Wealth Script is object oriented, supporting polymorphism. Cool....if the language supports OOD, I can work with it. I like to think that I'm language agnostic. But I noticed that in the sample scripts in the program, and the scripts you can view at Wealth-Lab.com, nobody uses classes. All the code is procedural.
So I started to write a DarvasBox object, and tried to encapsulate the state logic in the State Design Pattern. That's when I realized, once again, how lame wealth script is. I tried to overload the constructor (using the stupid constructor method qualifier keyword, followed by the name "Create" which seems to be their constructor naming convention). I got a compilation error saying that there is already a method named create. Just to make sure you understand that I didn't miss the obvious, the two Create definitions have different parameter signatures. Does wealth script actually support overloading?
Also, I tried to set a type reference to null, and got another compilation error. Is it possible that this "object oriented language" actually doesn't support null assignments?
I really wish there were a better, alternative. I took a look at Blocks, but it seemed too 4G-ish to me. You know....all visual drag and drop. It looks like you can edit code after it is auto generated from the 4G designer, but I'd rather just write things myself. I still haven't made my mind up on it.
