Pullback from 40 day high

D

Daybuck

New member
VIP
Hey guys, I need some help coding the following

Stock in a uptrend
Price hits 40 day high
price pulls back from 40 day high with 3 days of lower lows
The fourth day the closing price much trade higher than the closing price that was reached the previous day, the third day. Furthermore, the stock price must close in the upper 20th percentile of the daily trading range.

I don't know where to start coding so anybody that wants to tackle this it would be most appreciated. Thanks
 
T

tomsk

Well-known member
VIP
@Daybuck I took a look at your request, personally I think your conditions are a bit restrictive. Nevertheless I took a stab at constructing a scan based on the following three conditions:

(1) Uptrend
(2) Price hits 40 day high
(3) Price pulls back from 40 day high with 3 days of lower closes

With these 3 conditions I scanned against the S&P 500 and obtained 2 results and for the NASDAQ COMP I obtained 3 results. Hence you are not going to get too many hits with these tight conditions. The moment I added the 4th condition you specified, I got no results

That said, here is the scan I came up with. Place these directly in the scanner. This should bring you closer to what you seek

Code:
# Uptrend Scan
# tomsk
# 1.9.2020

# This scans for stocks with the following conditions
#
# [1] Uptrend
# [2] Price hits 40 day high
# [3] Price pulls back from 40 day high with 3 days of lower lows

IsAscending(close,20) and high == Highest(high,40) within 3 bars and sum(close < close[1], 3) >= 3

# End Uptrend Scan
 
Last edited:
D

Daybuck

New member
VIP
Thanks Tom for the quick response and code. I just thought it would be a good scan for strong stocks in an uptrend to get in on a small pullback. I am definitely open to any suggestions that may open it up a little and still accomplish what I am trying to do. Thanks again
 
T

tomsk

Well-known member
VIP
Nothing wrong with your request, it is a good start. One of the things you might try is to vary the length, so rather than 40 day high, use 21 day high, etc. You get the general idea. All the best!
 

Similar threads

Top