Swing trades are tough because essentially you're trying to predict what's going to happen overnight.
I mentioned "Red Floaters" after big run-ups, which can make for good shorts into the close.
However, just as you can use Johnny Vento's gap stat calculator for the probability of a gap-up, you can also use it for the probability of a gap-down.
So here's the idea behind this filter:
- We want stocks that have decreased 8-12% during the day. We can't have it less than that because there's too many stocks that will decrease 5% or so. We don't want it more than that because a stock that loses 15-20% has a good chance of bouncing the next day.
- We want stocks that have a past history of gapping down at least 70% of the time they've lost 8% of their value.
- We want reasonably liquid stocks (trading > 100000 shares)
- We want stocks that are not tied strongly to the overall market. We don't want a stock that is falling just because the market is falling. We want a stock that is falling on its own. Thus, it needs to have a Dow green/stock red correlation of more than 45%.
So here's the code. Please note that you need the "Advanced Stockfetcher" which is a bit more expensive than the standard. The standard Stockfetcher doesn't let you use complicated screens like this.
set {drop_threshold, 0.08} /* 8% drop */
set {OpCl , open - close}
set {OpClPct , OpCl / close}
set {met_down_threshold_Yesterday , count(OpClPct 1 day ago >= drop_threshold,1)}
set {gapped_up_today , count(open > close 1 day ago,1)}
set {gapped_down_today , count(open <>
set {met_down_threshold_then_gapped_up_today , met_down_threshold_yesterday * gapped_up_today}
set {met_down_threshold_then_gapped_down_today , met_down_threshold_yesterday * gapped_down_today}
set {met_down_threshold , count(met_down_threshold_yesterday >= 1,100)}
set {down_then_gapped_up , count(met_down_threshold_then_gapped_up_today >= 1,100)} set {down_then_gapped_down , count(met_down_threshold_then_gapped_down_today >= 1,100)}
set{gap_down_ratio, down_then_gapped_down / met_down_threshold}
set{gap_down_percent, gap_down_ratio * 100}
add column met_down_threshold
add column down_then_gapped_up
add column down_then_gapped_down a
dd column gap_down_percent
set{close_ind, ind(^DJI, close)}
set{open_ind, ind(^DJI, open)}
set{ind_diff, close_ind - open_ind}
set{ind_up, count(ind_diff > 0, 1)}
set{ind_down, count(ind_diff <= 0, 1)}
set{stock_diff, close - open}
set{stock_up, count(stock_diff > 0, 1)}
set{stock_down, count(stock_diff <= 0, 1)}
set{indup2, ind_up + 1}
set{inddown2, ind_down + 1}
set{stockup2, stock_up * 2}
set{stockdown2, stock_down * 2}
set{correlate_up, stockup2 + indup2}
set{correlate_down, stockdown2 + inddown2}
set{both_up, count(correlate_up equals 4, 100)}
set{both_down, count(correlate_down equals 4, 100)}
set{indupstockdown, count(correlate_up equals 2, 100)}
set{indownstockup, count(correlate_down equals 2, 100)}
set{indexupdays, both_up + indupstockdown}
set{indexdowndays, both_down + indownstockup}
set{indexupstockup, both_up / indexupdays}
set{indexupstockdown, 1 - indexupstockup}
set{indexdownstockdown, both_down / indexdowndays}
set{indexdownstockup, 1 - indexdownstockdown}
set{indexup_stockup, indexupstockup*100}
set{indexup_stockdown, indexupstockdown*100}
set{indexdown_stockdown, indexdownstockdown*100}
set{indexdown_stockup, indexdownstockup * 100}
add column indexup_stockdown
Open greater than Close
and OpClPct greater than drop_threshold
and OpClPct less than 0.12
and Volume greater than 100000
and Close less than 20
and Close greater than 1
and met_down_threshold greater than 10
and gap_down_percent greater than 70
and indexup_stockdown above 60
sort by column 8 descending
I ran this using Stockfetcher's "Backtest" function. I backtested it for the past 2 years. Only 19 stocks came up. The average return was 4.49%, and 12 out of 19 trades were winning trades. The reward/risk ratio was 3.65. The average max profit was 8.25%. A stop loss of 4% was triggered only 33% of the time. The average drawdown was -7.4%.
That's pretty good for a Stockfetcher backtest. It's a pretty stringent filter and you won't get many plays with it, but you'll get an occasional one.
EDITED TO ADD: I tweaked it so that the indexup_stockdown variable had to be more than 60. The win ratio improved to 75% of the trades as winning trades, an R/R ratio of 5.19 and an average profit of 6.14% (average max profit of 6.36%). Only 8 trades came up on the filter over 2 years, however.
HSNI came up on this filter yesterday. If you had shorted HSNI into the close near $2.80 yesterday, you would've had a 40% return on your position if you exited today at $2.



1 comments:
can you send me this code also and the corrected code for the co-relation calc
man you're on fire with this stuff!
Post a Comment