In Keith’s wonderful book, “Building Reliable Trading Sytems”, he reveals several algorithms that classify an instruments’ movement potential. In the part of the book that is titled Scoring by a Bar Type Criterion, he describes eight different two-day patterns that involve 3 different criteriaEight different Bar-Types
He looks at the relationship between today’s open and today’s close, today’s close and yesterday’s close, and today’s close in terms of the day’s range. Bar-Types 1 to 4 all have the close of today >= close of yesterday. Bar-Types 5 to 8 have close of today < close of yesterday.
I wanted to program this into my TradeStation and do some research to see if the concept is valid. In his book, Keith tested a lot of different stocks and commodities. In this post, I just test the ES, US, and Beans. This form of research can be used to enhance an existing entry technique.
Here is how I defined the eight different bar types:
array : barTypeArray[8](false);
midRange = (h + l)/2;
barTypeArray[0] = c >= c[1] and c > o and c >= midRange; barTypeArray[1] = c >= c[1] and c > o and c < midRange; barTypeArray[2] = c >= c[1] and c < o and c >= midRange; barTypeArray[3] = c >= c[1] and c < o and c < midRange; barTypeArray[4] = c < c[1] and c > o and c >= midRange; barTypeArray[5] = c < c[1] and c > o and c < midRange; barTypeArray[6] = c < c[1] and c < o and c >= midRange; barTypeArray[7] = c < c[1] and c < o and c <= midRange;
Defining Eight Different Bar Types
I used a brute force approach by creating an 8-element array of boolean values. Remember EasyLanguage uses a 0 index. If the two -day pattern matches one of the eight criteria I assign the element a true value. If it doesn’t match then a false value is assigned. I use an input value to tell the computer which pattern I am looking for. If I choose Bar-Type[0] and there is a true value in that array element then I take a trade. By providing this input I can optimize over all the different Bar-Types.
Input : BarTypeNumber(0), // which bar type buyOrSell(1), //1 to buy 2 to sell numDaysToHold(2); //how many days to hold position
For cnt = 0 to 7 //remember to start at 0 Begin If barTypeArray[cnt] = true then whichBarType = cnt; end;
If whichBarType = BarTypeNumber then begin if buyOrSell = 1 then buy this bar on close; if buyOrSell = 2 then sellshort this bar on close; end;
Loop Thru Array to find Bar Type
Here are some results of looping through all eight Bar-Types, Buy and Sell, and holding from 1 to 5 days.
ES – ten – year results – remember these are hypothetical results with no commission or slippage.
Here’s what the equity curve looks like. Wild swings lately!!
Beans:
Bonds
Keith was right – look at the Bar Category that bubbled to the top every time – the most counter-trend pattern. My Bar-Type Number 7 is the same as Keith’s 8. Here is the code in its entirety.
{Bar Scoring by Keith Fitschen from his book "Building Reliable Trading Systems" 2013 Wiley}
barTypeArray[0] = c >= c[1] and c > o and c >= midRange; barTypeArray[1] = c >= c[1] and c > o and c < midRange; barTypeArray[2] = c >= c[1] and c < o and c >= midRange; barTypeArray[3] = c >= c[1] and c < o and c < midRange; barTypeArray[4] = c < c[1] and c > o and c >= midRange; barTypeArray[5] = c < c[1] and c > o and c < midRange; barTypeArray[6] = c < c[1] and c < o and c >= midRange; barTypeArray[7] = c < c[1] and c < o and c <= midRange;
vars: whichBarType(0),cnt(0);
For cnt = 0 to 7 Begin If barTypeArray[cnt] = true then whichBarType = cnt; end;
If whichBarType = BarTypeNumber then begin if buyOrSell = 1 then buy this bar on close; if buyOrSell = 2 then sellshort this bar on close; end;
If barsSinceEntry = numDaysToHold then begin If marketPosition = 1 then sell this bar on close; If marketPosition =-1 then buytocover this bar on close; end;
Bar Scoring Example
Keith’s book is very well researched and written. Pick one up if you can find one under $500. I am not kidding. Check out Amazon.
Backtesting with [Trade Station,Python,AmiBroker, Excel]. Intended for informational and educational purposes only!
Get All Five Books in the Easing Into EasyLanguage Series - The Trend Following Edition is now Available!
Announcement – A Trend Following edition has been added to my Easing into EasyLanguage Series! This edition will be the fifth and final installment and will utilize concepts discussed in the Foundation editions. I will pay respect to the legends of Trend Following by replicating the essence of their algorithms. Learn about the most prominent form of algorithmic trading. But get geared up for it by reading the first four editions in the series now. Get your favorite QUANT the books they need!
This series includes five editions that covers the full spectrum of the EasyLanguage programming language. Fully compliant with TradeStation and mostly compliant with MultiCharts. Start out with the Foundation Edition. It is designed for the new user of EasyLanguage or for those you would like to have a refresher course. There are 13 tutorials ranging from creating Strategies to PaintBars. Learn how to create your own functions or apply stops and profit objectives. Ever wanted to know how to find an inside day that is also a Narrow Range 7 (NR7?) Now you can, and the best part is you get over 4 HOURS OF VIDEO INSTRUCTION – one for each tutorial.
This book is ideal for those who have completed the Foundation Edition or have some experience with EasyLanguage, especially if you’re ready to take your programming skills to the next level. The Hi-Res Edition is designed for programmers who want to build intraday trading systems, incorporating trade management techniques like profit targets and stop losses. This edition bridges the gap between daily and intraday bar programming, making it easier to handle challenges like tracking the sequence of high and low prices within the trading day. Plus, enjoy 5 hours of video instruction to guide you through each tutorial.
The Advanced Topics Edition delves into essential programming concepts within EasyLanguage, offering a focused approach to complex topics. This book covers arrays and fixed-length buffers, including methods for element management, extraction, and sorting. Explore finite state machines using the switch-case construct, text graphic manipulation to retrieve precise X and Y coordinates, and gain insights into seasonality with the Ruggiero/Barna Universal Seasonal and Sheldon Knight Seasonal methods. Additionally, learn to build EasyLanguage projects, integrate fundamental data like Commitment of Traders, and create multi-timeframe indicators for comprehensive analysis.
The Day Trading Edition complements the other books in the series, diving into the popular approach of day trading, where overnight risk is avoided (though daytime risk still applies!). Programming on high-resolution data, such as five- or one-minute bars, can be challenging, and this book provides guidance without claiming to be a “Holy Grail.” It’s not for ultra-high-frequency trading but rather for those interested in techniques like volatility-based breakouts, pyramiding, scaling out, and zone-based trading. Ideal for readers of the Foundation and Hi-Res editions or those with EasyLanguage experience, this book offers insights into algorithms that shaped the day trading industry.
For thirty-one years as the Director of Research at Futures Truth Magazine, I had the privilege of collaborating with renowned experts in technical analysis, including Fitschen, Stuckey, Ruggiero, Fox, and Waite. I gained invaluable insights as I watched their trend-following methods reach impressive peaks, face sharp declines, and ultimately rebound. From late 2014 to early 2020, I witnessed a dramatic downturn across the trend-following industry. Iconic systems like Aberration, CatScan, Andromeda, and Super Turtle—once thriving on robust trends of the 1990s through early 2010s—began to falter long before the pandemic. Since 2020 we have seen the familiar trends return. Get six hours of video instruction with this edition.
Pick up your copies today – e-Book or paperback format – at Amazon.com