In a previous article, Gap Strategy Tool, I demonstrated how you can use EasyLanguage to create a simple strategy that analyzes the percentage of times a gap closes. We broke gaps sizes up into "Groups" based upon their size. We then dtermined what was the probability of a gap clsoing based upon which group it belonged to. This information was displayed in the print log. It looked like this:
For each of the six different groups, the total number of gaps for that group is displayed along with the percentage of time the gaps close for that group. For example, gaps in Group 1 had a 35% chance of filling within the day while gaps in Group 6 had a 2% of filling in the day. Again, I recommend you review the first article, Gap Strategy Tool, for more detail on how this was done.
In this article, I'm going to approach our gap study differently. Instead of displaying information to the print log, we're going to use TradeStation's optimization feature to help us locate the best performing gaps. To me, this may be a better approach. Sure, we could continue to explore different filters and methods to categories gaps while printing out the different statistics, however, why not use the optimization feature to helps us locate the best combinations of filters and categories?
Let me show you what I mean by first converting our original strategy.
The first thing I did was move the gap size determination to a function called ELM_Gap_Size(). I then created an input called TradeGapGroup. This input allows us to optimize our different gap groups. When we do this we allow TradeStation to generate the performance for each of our gap groups and display them in the optimization report. Nice! Then we can easily review which gap groups have the best chance for success based upon the performance metrics.
Now, I took this a step further. Looking at the inputs you will also see a few more inputs.
The first input is GapTarget. Traditionally, our target for a gap trade is when price fills today's gap. However, I added a couple more to explore. A second target possibility is 1/2 the gap. A third target is 1.5 times the gap size. Our final target can be exiting at end of day. So, when performing an optimization you can optimize over 0-3 to test which profit targets to hit.
100% Gap Fill
50% Gap Fill
150% Gap Fill
End of Day Exit
The next input is TradeGapGroup. This was explained in our first article so I will not talk about it here. But you'll want to optimize 1-6 which represents the six different buckets of gaps sizes.
FadeOrRun. This one is interesting! Maybe we don't want to fade the gap. Instead, we want to go with the direction of the gap. For example, maybe price gaps down and we wish to take a short position in hopes price will continue to fall. We can now test this by toggling this on. This input can be a zero (gap fade) or a non-zero number (go with the gap). Note if this is enabled, our exit will always be end-of-day.
Finally, LSB stands for Long, Short, Both. This controls which direction we wish to trade. Most of the time I just leave this as a zero which means take both long a short trades. But you can set the optimizer to test all three possibilities.
Long & Short Bias
Short trades only
Long & short trades
Long trades only
Load this strategy on a chart and optimize the values we wish to explore. For example, I'll load this on the @ES market and optimize the following values:
This will result in TradeStation testing 48 different scenarios giving us insight to what type of gap strategy may work for the given market we're working with. Below is the performance report generated for this optimization.
The runs are organized based upon Net Profit. TradeStation automatically picked Test #36 (row highlighted in gray). What does this tell us?
We can see the selected GapGroup is 3. Thus, this is a mid-sized gap. We can also see the FadeOrRun setting is 1. This means we are not actually trading the gap fill. Instead, we are following the gap and holding the trade until the end-of-day. Thus, our GapTarget input has no impact. That's why the top performing optimizations have the same Net Profit with different Gap Target values.
So what are we trading?
We are looking for price gaps up or price gaps down that are sized between 40-59% of the five-day average ATR (a medium size gap). Aso, we don't fade the gap but place an order in the direction of the gap. So, if price gaps up we go long. If price gaps down we sell short. We close our trade at the end of the day.
Below is the equity curve of trading this particular gap setup.
Not a bad starting point! The first thing I noticed is the long side is the best performer. Lets look at long trades only.
This looks like an even better place to start building a complete trading system. Of course what we have here is not a gap strategy, but a breakout strategy! I didn't see that one coming. However based upon our test, gap fades are not as profitable as going with the gap. We located a specific scenario where going with the gap may become a profitable strategy.
Our results may change in the future as I plan to expand this tool in another article. Let me know your thoughts in the comments below.
Jeff is the founder of EasyLanguage Mastery - a website and mission to empowering the EasyLanguage trader with the proper knowledge and tools to become a profitable trader. Join our EasyLanguage FaceBook group to interact with other EasyLanguage traders! Click the FaceBook icon to join.
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.