Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

brownsfan019

Building a GAP Trading Strategy

Recommended Posts

I wrote some code awhile back for TradeStation as a starting point to a gap strategy, I'll post it here. If you run backtesting on it you'll soon realize that it doesn't make sense to risk real money trading it. However -- I haven't given up on it yet. I'm thinking about ways to filter out the entries so that you enter the trade under ideal conditions.

 

Those conditions could include using some type of trend determination filter such as Heikin Ashi, Momentum, Buying/Selling pressure etc.

 

If / when I come up with a decent solution I'll be happy to post the conclusion. In the meantime, feel free to play with the code if it helps.

 

DaveDM

 

----- Place the following in two separate Strategy documents in EasyLanguage, one for Gap Up and one for Gap Down...

 

 

// Gap Up Strategy

 

inputs:

Percent_Fill(.75), // 1 = 100%

Min_Gap_Size_Points(20), // 1 = 1 YM point

Max_Gap_Size_Points(101), // 1 = 1 YM point

Total_Contracts(1),

Take_Position_Start(935),

Exit_Positions_Time(1550),

Risk_Reward_Ratio(1.00);

 

variables:

 

mp(0),

Trade_Count(0),

Min_Gap_Per_Short(0),

Max_Gap_Per_Short(0),

Min_Short_Entry(0),

Max_Short_Entry(0),

Target_Short(0),

P_Close(0),

P_Open(0),

Gap_Size(0),

Stop_Price(0);

 

mp = marketposition;

 

 

// Gap Open, Direction Short

 

If time = Take_Position_Start then begin

if Trade_Count < 1 then begin

P_Close = CloseD(1);

// find bar number to reference for opening price of today

Value1 = FindBar(Date, Take_Position_Start);

P_Open = Open[Value1]; // Open price after Take_Position_Start time

Min_Short_Entry = P_Close + Min_Gap_Size_Points;

Max_Short_Entry = P_Close + Max_Gap_Size_Points;

Target_Short = P_Open - ((P_Open - P_Close) * Percent_Fill);

Stop_Price = P_Open + ((P_Open - P_Close) * Risk_Reward_Ratio);

 

if P_Open > P_Close then begin // Close[2]

if P_Open >= Min_Short_Entry then begin

if P_Open <= Max_Short_Entry then begin

sellshort ("SHORT") Total_Contracts contracts this bar;

Trade_Count = 1;

end;

end;

end;

end;

end;

 

// Short Exit

if mp = -1 then begin

if low <= Target_Short then begin // low

buytocover ("Target_Short_GU") next bar at market; // * or use limit order

// resets

Trade_Count = 0;

P_Open = 0;

P_Close = 0;

Min_Gap_Per_Short = 0;

Min_Short_Entry = 0;

Target_Short = 0;

mp = 0;

Value1 = 0;

Value2 = 0;

Value3 = 0;

Max_Gap_Per_Short = 0;

Max_Short_Entry = 0;

Target_Short = 0;

Stop_Price = 0;

end;

end;

 

// Stop Loss

if mp = -1 then begin

if high >= Stop_Price then begin

buytocover ("Stop_Loss_Ouch!_GU") next bar Stop_Price stop;

// resets

Trade_Count = 0;

P_Open = 0;

P_Close = 0;

Min_Gap_Per_Short = 0;

Min_Short_Entry = 0;

Target_Short = 0;

mp = 0;

Value1 = 0;

Value2 = 0;

Value3 = 0;

Max_Gap_Per_Short = 0;

Max_Short_Entry = 0;

Target_Short = 0;

Stop_Price = 0;

end;

end;

 

// Timed Exit since IntraDay trade only, exit all trades before market close

if mp = -1 and time >= Exit_Positions_Time then begin;

buytocover ("CLOSE_TIME") this bar;

// resets

Trade_Count = 0;

P_Open = 0;

P_Close = 0;

Min_Gap_Per_Short = 0;

Min_Short_Entry = 0;

Target_Short = 0;

mp = 0;

Value1 = 0;

Value2 = 0;

Value3 = 0;

Max_Gap_Per_Short = 0;

Max_Short_Entry = 0;

Target_Short = 0;

Stop_Price = 0;

end;

 

---- ^ that was the end of the gap up strategy. Place the following in a separate EasyLanguage strategy file for Gap Down.

 

 

// Gap Down Strategy

 

inputs:

Percent_Fill(.75), // 1 = 100%

Min_Gap_Size_Points(20), // 1 = 1 YM point

Max_Gap_Size_Points(101), // 1 = 1 YM point

Total_Contracts(1),

Take_Position_Start(935),

Exit_Positions_Time(1550),

Risk_Reward_Ratio(1.00);

 

variables:

 

mp(0),

Trade_Count(0),

Min_Gap_Per_Long(0),

Max_Gap_Per_Long(0),

Min_Long_Entry(0),

Max_Long_Entry(0),

Target_Long(0),

P_Close(0),

P_Open(0),

Gap_Size(0),

Stop_Price(0);

 

mp = marketposition;

 

 

// Gap Down, Direction Long

 

If time = Take_Position_Start then begin

if Trade_Count < 1 then begin

P_Close = CloseD(1);

// find bar number to reference for opening price of today

Value1 = FindBar(Date, Take_Position_Start);

P_Open = Open[Value1]; // Open price after Take_Position_Start time

Min_Long_Entry = P_Close - Min_Gap_Size_Points;

Max_Long_Entry = P_Close - Max_Gap_Size_Points;

Target_Long = P_Open + ((P_Close - P_Open) * Percent_Fill);

Stop_Price = P_Open - ((P_Close - P_Open) * Risk_Reward_Ratio);

 

if P_Open < P_Close then begin

if P_Open <= Min_Long_Entry then begin

if P_Open >= Max_Long_Entry then begin

buy ("LONG_ON_GD") Total_Contracts contracts this bar;

Trade_Count = 1;

end;

end;

end;

end;

end;

 

// Long Exit

if mp = 1 then begin

if high >= Target_Long then begin // high

sell ("Target_Long_GD") next bar at market; // * or use limit order

// resets

Trade_Count = 0;

P_Open = 0;

P_Close = 0;

Min_Gap_Per_Long = 0;

Min_Long_Entry = 0;

Target_Long = 0;

mp = 0;

Value1 = 0;

Value2 = 0;

Value3 = 0;

Max_Gap_Per_Long = 0;

Max_Long_Entry = 0;

Target_Long = 0;

Stop_Price = 0;

end;

end;

 

// Stop Loss

if mp = 1 then begin

if low <= Stop_Price then begin

sell ("Stop_Loss_Ouch!_GD") next bar Stop_Price stop;

// resets

Trade_Count = 0;

P_Open = 0;

P_Close = 0;

Min_Gap_Per_Long = 0;

Min_Long_Entry = 0;

Target_Long = 0;

mp = 0;

Value1 = 0;

Value2 = 0;

Value3 = 0;

Max_Gap_Per_Long = 0;

Max_Long_Entry = 0;

Target_Long = 0;

Stop_Price = 0;

end;

end;

 

// Timed Exit since IntraDay trade only, exit all trades before market close

if mp = 1 and time >= Exit_Positions_Time then begin;

sell ("CLOSE_TIME_GAP_DOWN") this bar;

// resets

Trade_Count = 0;

P_Open = 0;

P_Close = 0;

Min_Gap_Per_Long = 0;

Min_Long_Entry = 0;

Target_Long = 0;

mp = 0;

Value1 = 0;

Value2 = 0;

Value3 = 0;

Max_Gap_Per_Long = 0;

Max_Long_Entry = 0;

Target_Long = 0;

Stop_Price = 0;

end;

Share this post


Link to post
Share on other sites

We have done extensive gap trading testing over the SPI200 index futures. Please feel free to contact me for a copy of the test results.

 

regards

kevin

Edited by Soultrader
email postings not allowed

Share this post


Link to post
Share on other sites
We have done extensive gap trading testing over the SPI200 index futures. Please feel free to contact me for a copy of the test results.

 

regards

kevin

 

Go ahead and post here Kevin - you can upload a wide variety of attachments to the forum. No need for personal emails to be sent.

 

thanks

Share this post


Link to post
Share on other sites
Check out masterthegap.com

 

I subscribed to Scott Andrews' service for a couple of months. He uses statistical data to trade the opening gap everyday in the eminis.....plus pivot points etc. He does a pretty good job of it. I stopped subscribing because I wasn't trading futures at the time....now I am...so I'll probably subscribe again.

He put out a book called "Understanding Gaps" which is useful ;)

 

FWIW, I just got an email advertising a free webinar he is doing tomorrow.

 

Webcasts Details

 

I know nothing about him or his services, just passing on the info.

Share this post


Link to post
Share on other sites

I just started subscribing to the auto-trading program here thegapfill.com. He has back-tested results posted, and daily video of trades for the last month or so. Just started with it, so we will see how it goes.

Share this post


Link to post
Share on other sites
I found this somewhere, and thought it could be useful. It states the half gap fill is 80% winner. Of course you will still need correct money management (i.e. position size, stop loss) to make it profitable.

If anyone's going to take a statistical approach to this, make sure you use ample data. The xls attached on the quoted post uses a fairly small sample size. You may come to incorrect or statistically insignificant conclusions with not enough data. Also, the stats analyzed on the xls deal with specific day biases, which from my testing, are not as reliable or exploitable than biases rooted in market conditions (such as technical analysis, etc). It's a good start, but don't fool yourself with faulty statistics.

Share this post


Link to post
Share on other sites
If anyone's going to take a statistical approach to this, make sure you use ample data. The xls attached on the quoted post uses a fairly small sample size. You may come to incorrect or statistically insignificant conclusions with not enough data. Also, the stats analyzed on the xls deal with specific day biases, which from my testing, are not as reliable or exploitable than biases rooted in market conditions (such as technical analysis, etc). It's a good start, but don't fool yourself with faulty statistics.

 

I totally agree with what you are saying. I didn't put together the data, it could be totally bogus. I'm just wondering how you were able to determine the sample size? I also agree with you that technical analysis should be more valuable than specific day biases, though the fact that Monday has the lowest probability for a gap fill makes logical sense to me, and I think is valuable to know, and should be included in the overall analysis of the trade. The "special days" again should be included as statistically they do appear to have an effect.

Share this post


Link to post
Share on other sites

You want a few hundred gaps to look at, minimally. Basically, you're looking for biases (which should make sense), not find statistical flukes. Example, in the attached spreadsheet, 4pt gaps filled 86% of the time, 6pt gaps filled 77% of the time, but 5pt gaps only filled 60% of the time. That makes no logical sense, so I'd question the sample size just based on that.

Share this post


Link to post
Share on other sites

Mind you going back too far can be a two edged sword as market characteristics change over time. for example a market that trades in a 30 point range with 6 point gaps might be quite different to when it traded in a 12 point range with 4 point gaps. You need to also save enough data for walk forward testing. Oh and you need to ensure you have bull and bear and sideways data.

 

Has anyone considered combining gaps and an opening range break out type setup to determine if it is a gap and go or gap and close?

Share this post


Link to post
Share on other sites

The only gap fill strategy that has worked for me is to trade the ones that occur in the overnight session. Remember, the ES is a 24 hour market. It's not uncommon for gaps to occur between the close of the cash market to the next day's opening, but an examination of the overnight action may show no gap at all.

 

Overnight gaps may be few and far between, but the probability of filling is over 80%.

 

Also, there has to be some air between the gap and current price--I look for at least 5 points.

Share this post


Link to post
Share on other sites

Since I have been watching ES gaps (since I first stumbled on this thread) and I cut out off hours, the only consistent gap trade from my point of view is to trade candlestick patterns. This can still be very risky due to the RTH open madness. However I see no other way to trade this than using candlestick patterns. Just my observation. FWIW

Share this post


Link to post
Share on other sites
Since I have been watching ES gaps (since I first stumbled on this thread) and I cut out off hours, the only consistent gap trade from my point of view is to trade candlestick patterns. This can still be very risky due to the RTH open madness. However I see no other way to trade this than using candlestick patterns. Just my observation. FWIW

 

BR - that's basically what I've seen as well. I'm sure if we spent hours on it, there's so many other options but just glancing it would seem put up a 5 min (or longer chart) and buy the first hammer you see when it gaps down and vice versa. Some days, that's all it takes and 1 easy trade. Other days it's a matter of how many times you want to fire a bullet. My reco is 2-3 shots and then shut 'er down.

Share this post


Link to post
Share on other sites

ZOSO,

 

I don't like at overnight sessions that often, could you post a screenshot of an overnight gap if possible? Also what is the frequency of these gaps?

 

Thanks!

 

The only gap fill strategy that has worked for me is to trade the ones that occur in the overnight session. Remember, the ES is a 24 hour market. It's not uncommon for gaps to occur between the close of the cash market to the next day's opening, but an examination of the overnight action may show no gap at all.

 

Overnight gaps may be few and far between, but the probability of filling is over 80%.

 

Also, there has to be some air between the gap and current price--I look for at least 5 points.

Share this post


Link to post
Share on other sites

Dear Brownsfan,

 

I trade GAPs and found similar conclusions to your post UNTIL I found a website with probabilities for each gap and gap area in relation to the high close open and low of the previous day This gut ONLY trade gaps with an amazing Equity curve. Check it out at masterthegap.com

 

Regards

JM

Share this post


Link to post
Share on other sites
I have a decent amount of experience here, so will share some if anyone wants to look into this. I have an automatic strategy that trades gaps on ES that has a fairly impressive track record. This isn't my primary method of trading, but was one of my first statistical looks at markets, and has helped smooth out the P/L curve. It trades using statistical biases I've found, and only actually attempts roughly 20-25% of the time (but it's actually highly accurate, and has a good r:r). In turn, many of the "gap and go" days are filtered out.

 

For those who are statistically inclined, here are some things to look into regarding statistical biases for gaps. Remember, if the gap filled or not is only one side of the coin. Also look at the bias in context of the gap size and risk.

  • Is the general market trending or congesting?
  • How big is the gap? (I have filters for gaps that are too big, and too small)
  • How does gap size compare to ATR? (same)
  • Have the previous x gaps filled? (look at both the direction of the gap, and against)
  • How does gap direction compare to the trend direction? (look at a few timeframes)
  • Where is the gap positioned compared to the previous day's value area? (ie, is there liquidity close by?)
  • Where is the gap located compared to yesterday's High and Low? (inside/outside)
  • What day of the week is it? (yes, there's a bias)
  • How volatile has the market been?
  • Is the gap near S/R? (this is one of the hardest to automate, so sometimes you end up cutting corners)

 

This list is by no means complete, and I'd encourage someone who wants to delve into this look into these suggestions along with any other ideas they may have. I simply got a decent amount of historical data (think a couple years), and did some testing for each of my potential biases in Mathematica (Excel also works well for this) with a portion of the data. Once I had a good idea of a potential bias, I tested it on out of sample data.

 

When combined, these biases give you a much better idea of the statistical edge you may have by trading any given gap. I programmed the strategy to enter anywhere from 9:00 to 9:45 on a technical trigger (for brownsfan's case, he looked at hammers; you may prefer some type of indicator or other method). Exits are enabled within a certain % of the gap fill, and exit on a similar technical trigger (so they may go past the gap).

 

Hope this gives budding statisticians some ideas. In addition to biases, stop strategy is very important (and could be a bias in itself.. if price goes x% against, what's the chance it'll go back and fill?). Something mine does not do is the "bullets" approach, and there could be some validity in that.

 

Hope I didn't barge in on your candlestick discussion, browns :)

 

Dear Browns

 

You said : "but was one of my first statistical looks at markets"

 

I am very interested in this strategy, but organizing the data and KNOWING where and what to look for is very unclear, Can you point me in the right direction to learn how to get useful data ?

 

I really will appreciated it !

 

Regards

 

Jaime

Share this post


Link to post
Share on other sites

I was reading through this thread. Motivation was this website publishing unique strategy to trade gaps, their strategy is not exactly gap as they call it open out of previous days range. Just bumping an old thread but I think anyone interested in gap trading may find the setups useful

Edited by edakad

Share this post


Link to post
Share on other sites

Firstly we need to know what is a gap trading strategy.Basically gap trading is a simple and disciplined approach to buying and shorting stocks. Essentially one finds stocks that have a price gap from the previous close and watches the first hour of trading to identify the trading range. Rising above that range signals a buy, and falling below it signals a short.

 

A gap is a change in price levels between the close and open of two consecutive days. Although most technical analysis manuals define the four types of gap patterns as Common, Breakaway, Continuation and Exhaustion, those labels are applied after the chart pattern is established. That is, the difference between any one type of gap from another is only distinguishable after the stock continues up or down in some fashion. Although those classifications are useful for a longer-term understanding of how a particular stock or sector reacts, they offer little guidance for trading.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Topics

  • Posts

    • Date: 25th April 2024. Investors Monitor a Potential Japanese Intervention, and upcoming Tech Earnings. Meta stocks top earnings expectations, but revenue guidance for the next 6 months triggers significant selloff. Meta stocks decline 15.00% and the Magnificent Seven also trade lower. Japanese Authorities are on watch and most market experts predict the Japanese Federal Government will intervene once again. The Japanese Yen is the day’s worst performing currency while the Australian Dollar continues to top the charts. The US Dollar trades 0.10% lower, but this afternoon’s performance is likely to be dependent on the US GDP. USA100 – Meta Stocks Fall 15% On the Next 6-Months Guidance The NASDAQ has declined 1.51% over the past 24 hours, unable to maintain momentum from Monday and Tuesday. Technical analysts advise the decline is partially simply a break in the bullish momentum and the asset continues to follow a bullish correction pattern. However, if the decline continues throughout the day, the retracement scenario becomes a lesser possibility. In terms of indications and technical analysis, most oscillators, and momentum-based signals point to a downward price movement. The USA100 trades below the 75-Bar EMA, below the VWAP and the RSI hovers above 40.00. All these factors point towards a bearish trend. The bearish signals are also likely to strengthen if the price declines below $17,295.11. The stock which is experiencing considerably large volatility is Meta which has fallen more than 15.00%. The past quarter’s earnings beat expectations and according to economists, remain stable and strong. Earnings Per Share beat expectations by 8.10% and revenue was as expected. However, company expenses significantly rose in the past quarter and the guidance for the second half of the year is lower than previous expectations. These two factors have caused investors to consider selling their shares and cashing in their profits. Meta’s decline is one of the main causes for the USA100’s bearish trend. CFRA Senior Analyst, Angelo Zino, advises the selloff may be a slight over reaction based on earnings data. If Meta stocks rise again, investors can start to evaluate a possible upward correction. However, a concern for investors is that more and more companies are indicating caution for the second half of the year. The price movements will largely now depend on Microsoft and Alphabet earnings tonight after market close. Microsoft is the most influential stock for the NASDAQ and Alphabet is the third. The two make up 14.25% of the overall index. If the two companies also witness their stocks decline after the earnings reports, the USA100 may struggle to gain upward momentum. EURJPY – Will Japan Intervene Again? In the currency market, the Japanese Yen remains within the spotlight as investors believe the Japanese Federal Government is likely to again intervene. The Federal Government has previously intervened in the past 12 months which caused a sharp rise in the Yen before again declining. The government opted for this option in an attempt to hinder a further decline. Volatility within the Japanese Yen will also depend on today’s US GDP reading and tomorrow’s Core PCE Price Index. However, investors will more importantly pay close attention to the Bank of Japan’s monetary policy. Investors will be keen to see if the central bank believes it is appropriate to again hike in 2024 as well as comment regarding inflation and the economy. In terms of technical analysis, breakout levels can be considered as areas where the exchange rate may retrace or correct. Breakout levels can be seen at 166.656 and 166.333. However, the only indicators pointing to a decline are the RSI and similar oscillators which advise the price is at risk of being “overbought”. Always trade with strict risk management. Your capital is the single most important aspect of your trading business. Please note that times displayed based on local time zone and are from time of writing this report. Click HERE to access the full HFM Economic calendar. Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding on how markets work. Click HERE to register for FREE! Click HERE to READ more Market news. Michalis Efthymiou Market Analyst HFMarkets Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in FX and CFDs products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • $ALVR AlloVir stock bottom breakout watch, huge upside gap, https://stockconsultant.com/?ALVR
    • $DIS Disney stock attempting to move higher off the 112.79 triple support area, https://stockconsultant.com/?DIS
    • $ADCT Adc Therapeutics stock flat top breakout watch above 5.31, https://stockconsultant.com/?ADCT
    • $CXAI CXApp stock local support and resistance areas at 2.78, 3.52 and 5.19, https://stockconsultant.com/?CXAI
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.