02 Feb Second Day Gap Day Trading Strategy
If you are having difficulty finding an edge or need a little guidance where to start then read the following post. Here we will evaluate a mean reversion gap algorithmic trading strategy. We will work together on the day trading strategy and find a new perspectove to our original hypothsesis. To improve our strategy, we will modify the risk to reward on each trade. So let’s start:
1. What Is An Algorithmic Trading Edge?
An edge is a positive expectancy on a given trade, just like a casino has a statistical probability of success on blackjack hand. Many think an edge is some elusive holy grail or something so complicated only Nobel prize winners have the ability to come up with one. My answer is always the same, “an edge can be super simple or super complicated, it all depends on your style of trading and account size” . The best edges are ones that can expose a true inefficiency in the markets but there are others which work of simple repeatable habits of the market. For information on Finding a Daytrading Edge click this link.
2. Market Have a Tendency To Mean Revert
Many daytraders understand that markets tend to go to one extreme to another very quickly. Often when there is a big selloff then after a couple of days we have a tremendous bounce or retracement, this can often occur on the same day. This is due to market balance: when markets start dropping fast, the player’s positions in the market become out of whack. It takes time for markets to ride out the storm and find a balance between supply/ demand and in the process of finding that balance the market will try to “screw over as many players as possible”. Fear and greed is a natural trait in human evolution and is ever present in the futures markets. Even algorithms can suffer from the same problem as ultimately they are still programmed by humans which themselves are trying to capture the inefficiency of that fear and greed.
3. Creating A Simple Mean Reversion Algorithmic Trading Strategy
Many traders, particularly retail traders like Gap trading, they have a fascination with overnight gaps with futures trading. It is almost as the collective will of all players in the market for gaps to eventually fill – it becomes a sort of selffulfilling prophecy. There are actually reasons why gaps do fill (which I won’t get into here) but let ‘s try some ideas to find a system involving gap trading.
One Day Gap Fill Algorithmic Trading Strategy
First lets simply program an ES trading system (market ES Emini) to see if there is an edge to gap trading with a single day gap. I am testing this in Multicharts using Esignal data – I have included commission and slippage and we assume our limit orders fill when price trades through.
Using regular Emini Central Time hours from 08:30 to 15:15 (when cash markets are open) we evaluate any gaps made overnight on GLOBEX futures market. Couple of things we need to program into the system:
What constitutes a gap?

 We declare in this case that a gap is considered today’s opening price is greater/less than yesterdays close by 10% of yesterdays range (you can try use daily ATR or any other value which represents expected daily range):


if newday and openingPrice < (ydayClose  (ydayRange*0.1) then begin GapDown +=1; //counts if there is a gap GapUp = 1; GapPresent +=1; end;
 So above you see the code to get a gap counter going (we do a similar thing to get up gaps). So now we enter positions short/long for gap up/gap down. We do this at the opening pri ce as a market order. e.g:

//ENTRY LONG HERE if marketposition = 0 and time = start of new day and GapDown >1 then begin buy ("long") 1 contracts next bar at market; end;
 We can now place some simple stops and targets into our ES trading strategy. Our target is yesterdays close as a gap fill being the target and our stops are simply entry price + yesterdays range (short entries) or entry price – yesterdays range (long entries).
 There is further code to assume the gap counters are correct and reset back to 1 everytime a gap is filled.


Gap Trading Strategy Results
 Profit factor is the most important metric to use when evaluating the results: it can be seen that Long entries have close to 1 profit factor (even) and that is taking into account slippage and commission.
 We could easily try different stops and targets and get closer to a profitable strategy, however, I would not pursue this any further because the entry has very little merit so no point expanding and creating filters for a negativeexpectancy entry rule.
4. Turn This Losing Algorithmic Trading Strategy Into A Winning One Using Second Day Gaps Only
A lot of day traders know that even though single gap days fail often a double gap day on the major indexes will close. The only problem is that the number of trades will be limited and the system will trade infrequently. So let’s test the same system but now we only enter if there are two gaps in a row (either an up gap or down gap with previous days gap remained unfilled).
We add the following logic to our code:
 If there is a gap on a single day and this gap fills atleast 90% of the gap value then we presume this gap to be closed and the gap counter to be reset to zero.
 If we have an open unfilled gap up or down yesterday and then today’s open is also a gap up or down – we can enter long/short at the market on the opening of the market.
 As can be seen, the long secondday gaps strategy is pretty much flat with profit factor 0.97 including transaction costs but the short secondday gap strategy is positive with profit factor 1.4. The only issue is that we only have 182 short trades and 186 long trades for our sample (which is quite low).
This is just one example of trying to find an edge with algorithmic trading. I am simply demonstrating something which an individual trader may have observed and now is testing whether there is any positive expectancy to their hypothesis. Even if something does not work we can think of other things around the original hypothesis which might work e.g., in this case, we went for two gap days in a row. When looking for ideas always try to be creative, especially if you are looking for repeatable patterns or behaviour.
5. Adjusting Targets For Our Daytrading Strategy
From the previous example of secondday gap strategy results, I find it interesting that the short side made money, so I wanted to test why the long side does not make money. By looking at many of the trades manually what I find is that either the target is too small or stop is too big. So by following the old adage , we implement targets having a lower risk to higher reward on each trade – I consequently used an Average True Range stop and target and set it so targets were at twice the ATR than the stops. We have a small risk and bigger reward for each trade.
 Using a different stop and target rules and modifying the risk ratios we now get the following results:
 Both longs and shorts are now profitable. The longs have very small profit factor and shorts profit factor has actually improved and is now 1.69. The number of trades made is the same as before.
 When evaluating a strategy we aim to have a smooth equity curve – if you do not have this then that means your strategy cannot perform in multiple market environments. We also want each year to be profitable either in bull or bear market, high volatility or low volatility the strategy should still perform.
 So the equity curve has some sharp drawdowns and is quite jagged but still, the system has been profitable each and every year apart from 2014 (and even then the loss was very small).
 Adjusting risk to reward for a trading strategy can change performance significantly, traders must assess what type of stops/targets to be used or whether stops or targets should be used altogether?
6. Conclusion
For any new daytrader or potential algorithmic trader, we can see from this post that we can pretty much start with a simple hypothesis and then work on the same hypothesis from a different angle. Then we can examine by modifying risk/reward for the strategy we can change a losing strategy into a winning one.
If you wanted to continue with this particular strategy you could figure out and design filters where you expect this system to fail.
Why We Would Not Trade This Strategy
Even though the filtered secondday gap algorithmic trading strategy shows some promise and is especially good on the short side we would not continue perusing this strategy or improving it for the following reasons:
 The backtest trade sample is too small, we would prefer at least 250 trades short and long each minimum.
 The strategy performs poorly on long side without the new stops/targets – this shows us that the initial edge or entry does not show massive potential or positive expectancy.
 The profit factor is less than 1.8. With a day trading strategy with the number of trades less than 250 long or short you would expect much higher profit factor. With our own Alpha Equivalence Bot, automated trading system: see the performance metrics for strong systems.
 When the strategy was tested we should have bootstrapped our data and performed both in the sample and out of sample testing – the backtesting done in the manner in this post is biased and incorrect.
 To see results of a strategy we would trade and one which every daytrader should aim to emulate is our:Alpha Equivalence Bot
In summary, I hope this post demonstrates that you can pretty much test and find an edge multiple ways – even testing sometimes a silly assumption might yield promising unexpected results. Please keep following our algorithmic trading blog to see new updates and example edges.
Start Algorithmic Trading Today
Request pricing and more information about algorithmic trading systems. Our CEO will contact you personally.
Sorry, the comment form is closed at this time.