Let’s try to improve upon the gap strategy that was provided by Ben Little’s article entitled, “Testing A Simple Gap Strategy.” In this article Ben demonstrated a simple trading model, called Gap Fade 31, based upon the opening gap in the S&P futures market. This was the first gap based article on System Trader Success and it drew a fair amount of attention. Personally, I’ve not looked at gap strategies since 2008. I never did find a gap strategy that I liked. However, I thought this would be a good time to review some concepts I’ve not reviewed in many years.
This trading model opened positions in the opposite direction of a gap. Thus, up-gaps were faded by going short and down-gaps were opportunities to go long. A hard stop value and profit target were placed after a new position was opened. For a more complete description please see the original article.
The trading model utilized two important filters.
Ben tested the validity of the regime filter in the original article. By the term “validity” I’m referring to the regime filter to provide value. Clearly the regime filter provided value by reducing unproductive trades and dramatically improved results as seen in the original article. The regime filter forces the trading model to take long trades only taken during a bull regime and short trades only taken during bear regimes. This makes logical sense and helps give credence to the model. Ben also tested the robustness of the regime filter which held up well.
Because I plan on running some tests I’m going to break my historical data into two portions. An in-sample portion and out-of-sample portion. Thus, when I’m finished with my back-testing I’ll have a portion of the data to test the modified trading model on.
Before getting into the details of the results, let me say this: all the tests within this article are going to use the following assumptions:
Based upon our assumptions above, here is the baseline performance of the trading model. I’ve also attached the TradeStation performance report: Gap_Strategy_Baselin.xls.
I would like to test the validity of the range filter. So, in the test below I simply removed the range filter allowing the trading model to take trades that were outside of the previous day’s range.
Here we clearly see that avoiding trades that fall outside of the previous day range improves the results. The range check is valid.
Back in 2008 when I was looking at gap-based trading models, testing day -of-the-week filters was common practice. I remember it was often demonstrated that particular days of the week should be avoided as they continually produced negative results. Let’s see how that looks today with this model.
In this bar graph the x-axis represents the day of the week and the y-axis is the net profit accumulated for taking all trades during that particular day of the week. The first bar is Monday (1), and the last bar (5) is Friday. We can see that Monday and Friday have not produced very good results overall. Not taking gap trade on these days may be a good idea
The code for this strategy is at the bottom of this article.
I distinctly remember that the size of a gap also played a roll in determining if a particular trade would be ignored or not. I don’t recall completely, but I think too large of gaps or too small of gaps were avoided. Let’s see what we have going for us today.
I’ve modified the code to take two inputs:
Gap Increments tells the software the size range of gaps that we will be trading. For example, a gap increment of 5 states we are testing gaps that fall within a 5 point range.
Iterations tell the software how many different scenarios we are testing. It is this input value where we use TradeStation’s optimization feature to perform iterations over the trading model while testing different gaps sizes. Based on how the software works, it’s important to start this input value from zero. For example, if we want to perform 6 iterations we would enter zero here and then use the optimizer to test from 0-5. That means we will be performing 6 tests with a gap increment of five. This would generate the following tests:
|0||0 – 5 pts|
|1||5 – 10 pts|
|2||10 – 15 pts|
|3||15 – 20 pts|
|4||20 – 25 pts|
|5||25 – 30 pts|
So in the above example we would have 6 different tests. The first test would only trade gaps greater than 0 and less than or equal to 5 points. The second test would only trade gaps greater than 5 and less than or equal to 10 points. And so on…
Here are the results when I tested the trading model with a gap increment of 1 with 25 iterations.
Looking at this bar graph we can see gaps sizes at bar #8 is the last bar to produce profits. Bars to the right of #8 produce no profits. Bar #8 represents gaps less than or equal to 9 points and greater than 8 points. In the end it looks like we can improve the system by only taking gaps that are equal to or less than 9 points.
The code for this strategy is at the bottom of this article.
Let’s now take what we learned and apply it to our baseline system. First, we apply the day-of-the-week filter (DOW) to our baseline system.
Here we apply the gap size filter to our baseline system.
In this test I combined the day-of-week filter with the gap size filter.
At this point I like the day-of-week filter better than the gap size filter. I like the fact that the net profit per trade and profit factor is larger than the gap size filter. Furthermore, we already have a gap size filter in place with our range check. Thus, I really don’t feel too comfortable adding an additional check on the gap size.
After coming up with these two filters and testing them on our in-sample data, we can now apply them to our out-of-sample data. For now however, I”ll be doing this in another article as this article is getting a bit long. Once we test our idea on the out-of-sample data we’ll see if our efforts paid off or if it’s back to the baseline system to try new ideas.
Below are some TradeStation performance reports based upon comments below.
Jeff is the founder of System Trader Success – a website and mission to empowering the retail trader with the proper knowledge and tools to become a profitable trader the world of quantitative/automated trading.
Please log in again. The login page will open in a new window. After logging in you can close it and return to this page.