Improving The Simple Gap Strategy, Part 1

About the Author Jeff Swanson

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.

follow me on:
  • Alex says:

    Waiting for out-of-sample test. What about providing Sharpe values?

    • Hey Alex. Not a big fan of Sharpe values.

      • Alex says:

        Sharpe ratio is too important to neglect. Maybe you like Sortino ratio instead?

        • Pete S says:

          Results are too important to neglect. How you chose to assess them is subjective. Sharpe, Sortino, CAR/MDD, RAR/MDD etc. Take your pick, we are all free to chose. I think that also applies to Jeff….

          • Alex says:

            I remember the story of a guy who worked for a fund and one day he told his boss that he did not like the Sharpe ratio. Security came and kicked out of the building along with his things and a pink slip.

            Do you understand that Sharpe ratio is like a signal to noise ratio? Do you understand that statistical significance of an algo is tight directly to Sharpe ratio? Do you understand that those who do not report Sharpe ratio values have at times something to hide?

          • If I can jump in to this…the Sharpe ratio is available. Simply download the code and execute it on your platform. This trading model is open source so there is nothing to hide. For me, Sharpe ratio at this stage in the development process is not needed. Particularly, when the trading model is not even tested on OOS data yet. But that’s just my opinion.

  • Paul Mayer says:

    Can you provide a download of the txt version of the code? I have been interested in testing variations on a gap-fill strategy for some time, and unfortunately I can never open your .eld files and need .txt since I use Multicharts instead of Tradestation.

    I really appreciate your articles and the generosity of you sharing your work with others.

    • Hey Paul. Glad you are liking the articles. There are two text files available in the download section of the article. They are the gap strategy code with the two different filters. You can strip out the filters have just the baseline system. Does this help?

  • Marco says:

    I remember Larry Williams to use a gold momentum filter and a bond momentum filter to one of his intraday volatility strategies. Maybe this can help in adding other filters.

  • Enrico says:


    did anyone try to isolate long and short results?

    Thank you


  • Enrico says:

    Thanks for your work Ben,

    my idea in testing long and short trades was mainly referred to the “long bias” that the stock market has, especially in some days of the week. So it would be interesting to know (I can’t do that because i don’t have tradestation available) how the winning percentage of both long and short trades work out during the days of the week. Maybe we could find some interesting ideas.

    Thank you


  • Robert Jacobson says:

    I’d be cautious with drawing too many conclusions from a day-of-week filter. When you segregate the trades by day-of-week, you end up with a relatively small sample size for each day, so your day-by-day results might not be entirely reliable.

    For what it’s worth, I tested your strategy on MultiCharts. I only have access to minute data from September 2006 to the present. However, within this sample, I ended up with completely different results — Monday was OK (profit factor of 1.42), and Wednesday was a stinker (PF of 1.11). None of the days were unprofitable, though.

    Also, as a coding suggestion, it might be easier to encode the DayToTest input as a numeric variable. I.e., Monday = 1, Tuesday = 2, etc. Then, you can simplify your code through something like:

    ValidGapDay = (DayOfWeek(Date) = DayToTest);

    That way, your code would be shorter, and you could also run an optimization on the input from 1 to 5 to get all of the results in one pass.

    • Robert Jacobson says:

      One other thought — as you and Ben noted, the strategy didn’t perform very well in the late 1990’s and early 2000’s. Is it possible that this is attributable to the switchover from pit trading to electronic trading? Perhaps this strategy didn’t work as well back in the pit days.

      (I’m not sure when the majority of the volume switched from pit to electronic — if someone has that information, that would be good to know.)

      • That could be part of the reason for sure. Around the year 2000 or just after, there did seem to be a major shift in the markets. Some would say since 2008, a new shift has taken hold as futures volume has fallen dramatically in a world of zero interest and high frequency trading.

    • I agree. The main reason for this is I can’t think of a reasonable reason on why a particular day should or should not work. I feel much better when I apply a particular filter that as a logical reasons on why it should work. But this one, I can’t think of one. Nonetheless, I included this as I remember day-of-the-week was a filter often discussed. Thanks for the code suggestion.

  • Enrico says:

    I am quite curios to know if the performance of the short trades is similar to the long ones.
    It is the historical up bias of the stock market which makes me think.

    • I’ve uploaded a copy of the TradeStation Performance Report for the Baseline system. You will find the short trades perform slightly better! This surprised me as I would think the same thing as you did Enrico in regards to the historical up bias.

  • Enrico says:

    Thanks for that Jeff; did you use the 200/500 settings for the take profit/stop loss values?

  • Enrico says:

    Are there any changes in the overall performance about opening a position exactly at the opening at 8.30 or at 8.31 one minute later?

    • That’s an interesting idea. It would be hard to test the 8:30 open precisely using minute bars. But you could change the session templates so that the session opens one minute earlier (at 8:29), and then run the test at the end of the 8:29 minute bar.

    • Check at the bottom of the article, I just added some new TradeStation performance reports.

  • Enrico Tomat says:

    How much interesting are the ‘unbalanced’ results in the ’25 and ’29 tests regarding long and short results. Food for thought.

  • Enrico Tomat says:

    Thank you Jeff

  • Enrico Tomat says:

    I don’t know if you get my last post, but it is very interesting to notice how the long trades performance changes as we change the time of opening the position.

  • May says:

    Glad to find your website.

    1. I open the TS workspace but it shows :
    “Unable to allocate memory for large data request, reduce
    the range of dat being requested.”

    2. No trade result find in :
    Strategy With Day-of-Week Filter
    Strategy With Gap Size Filter

    I don’t know what is wrong ?

    • There is a lot of historical market data being used. Your error may be happening due to a problem related to available computer resources (memory). Reboot your computer and give it a try again. If that does not work, you may want to limit the historical data to only 5 years or so.

  • Hari says:

    Hi Jeff,
    Thanks a lot for sharing your work. I really enjoy reading all your articles.
    Regarding day-of-the-week filter, I found 2 similar references which also show Monday and Friday are less favorable for fading the gap.

    Gap fading prob –a) Win Rate –b)
    Monday 66.6% 70.8%
    Tuesday 70.0% 74.0%
    Wednesday 71.2% 76.5%
    Thursday 73.4% 73.9%
    Friday 67.4% 72.4%

    (a-Gap fill analysis ES from 19 Oct 1999 to 16 Oct 2009 …
    (b-Win Rate by day of the Week 1998 – 2006 … Scott Andrews, Understanding Gaps

    Mark Austin in his training on fading FTSE gap mentioned this issue. According to Mark, Monday is the weakest day for closing gap. Some significant events can happen over the weekend and also many people get a chance to read and analyze the situation during this time. By Monday morning, they have decided whether to buy or sell and therefore Monday is less likely for gap to close. Friday however is a good day to short the up gap because many share traders would like to take profit and close their position heading to the weekend.

  • Christian says:

    Hi Jeff,

    high five for sharing. How about session hours? Which do you use on the ES for this strategy?

    • It’s the standard session hours. 8:30AM Central open and 3:15PM Central close.

  • Rich S. says:

    Hi Jeff,

    On the baseline system, if you optimize the Stop loss and profit target simultaneously and then plot the results on a 3-D graph, will give a different point of reference for a robust system.

    Using this process, I found that StpLs = 500 and PrfTg = 400, was a bit more robust solution even though the Total Profit suffered somewhat.

    Thanks again for this series.

    Rich S.

    • Rich, those are similar numbers the original author of the system came up with as well. I think my next test will be to look at more dynamic stops and targets based upon the size of the gap.

  • Cameron Osborne says:

    Hi Jeff, thanks for your work. I would be really interested in the application of this filter:

    I have been using this article for some time now trading Russell, SP500, DOW, NASDAQ futures. There is usually a trade every day between the big 4. The filter would be if any of the following are TRUE:

    1. Yesterday’s candle was a bullish candle (C > O), Today’s open is between yesterday’s open and close. Go Long.

    2. Yesterday’s candle was a bullish candle (C > O), Today’s open is between yesterday’s close and high. Go Short.

    3. Yesterday’s candle was a bearish candle (C < O), Today's open is between yesterday's open and close. Go Short.

    4. Yesterday's candle was a bearish candle (C < O), Today's open is between yesterday's close and low. Go Long.

    These are the highest probability zones of gap filling. The link here is something I just uploaded. This is SPY data since January 1993 showing the 10 possible gap trading zones and their continuous average success of filling the gap to present day. The success rates mean that the gap was filled that same day. The fat black line shows about 70% of all gaps no matter the zone fill the same day. I grouped the trades based on:

    U- : Yesterday was an 'up' day (bullish candle)
    D-: Yesterday was a 'down' day (bearish candle)

    U-HC: Yesterday was an 'up' day, and the open today was between yesterday's High and Close (HC)
    D-CL: Yesterday was a 'down' day, and the open today was between yesterday's Close and Low (CL)

    I grouped the similar categories together with dashed and solid lines so that it is easier to understand what is happening. There is a clear bias to trading the gaps based on zones.

    Maybe a gap trading part 3 article?

    Thanks again for your work.

    • Thanks for posting. I’m planning on incorporating this very filter into a future article. It’s a filter I’m aware of and have tested, many years ago. However, nothing really materialized into a viable trading system. Yet, I think it’s worth revisiting.

  • Cameron Osborne says:

    Sorry, the link I mentioned that never manifested is here:


  • >