Thanks to MJ for planting the seed for this post. If you were one of the lucky ones to get Keith’s “Building Reliable Trading Systems – Tradable Strategies that Perform as They Backtest and Meet Your Risk-Reward Goals” book by John Wiley 2013 at the list price of $75 count yourself lucky. The book sells for a multiple of that on Amazon.com. Is there anything earth shattering in the book you might ask? I wouldn’t necessarily say that, but there are some very well thought out and researched topics that most traders would find of interest.
In his book Keith discusses the concept of bar-scoring. In Keith’s words, “Bar-scoring is an objective way to classify an instrument’s movement potential every bar. The two parts of the bar-scoring are the criterion and the resultant profit X days hence.” Keith provides several bar scoring techniques, but I highlight just one.
Keith broke these patterns down into the relationship of the close to the open, and close in the upper half of the range; close greater than the open and close in the lower half of the range. He extended the total number of types to 8 by adding the relationship of the close of the bar to yesterdays bar.
The PatternSmasher code can run through a binary representation
for each pattern and test holding the position for an optimizable number of days. It can also check for long and short positions. The original Pattern Smasher code used a for-loop to create patterns that were then compared to the real life facsimile. In this code it was easier to just manually define the patterns and assign them the binary string.
Please check my code for any errors. Here I go through the 8 different relationships and assign them to a Patter String. “-+++” represents pattern number (7 ) or type (7 + 1 = 8 – my strings start out at 0). You can then optimize the test pattern and if the test pattern matches the actual pattern, then the Pattern Smasher takes the trade on the opening of the next bar and holds it for the number of days you specify. You an also designate long and short positions in the code. Here I optimized the 8 patterns going long and short and holding from 1-4 days.
Here is the equity curve! Remember these are Hypothetical Results with $0 commission/slippage and historic performance is not necessarily indicative of future results. Educational purposes only! This is tested on ES.D
Play around with the code and let me know if you find any errors or any improvements.