Scan close of 5 min bar crosses above yesterday’s close or high


Category:
0
0

Hello,

Is there a way to scan whenever current closing price of a 5 min bar crosses above yesterday’s close or yesterday’s high. Please see screenshot for details.

Attachments:
RESOLVED
Marked as spam
Posted by (Questions: 7, Answers: 8)
Asked on October 26, 2018 8:02 am
154 views
0
Private answer

I think this should do it.

def newDay = GetDay() <> GetDay()[1];
rec highOfDay = if newDay then high else if high > highOfDay[1] then high else highOfDay[1];
rec prevDayHigh = if newDay then highOfDay[1] else prevDayHigh[1];
rec prevDayClose = if newDay[-1] then close else prevDayClose[1];
# use this to scan for close crossing above previous day high
plot scan = close[1] <= prevDayHigh and close > prevDayHigh;
# use this to scan for close crossing above previous day close
#plot scan = close[1] <= prevDayClose and close > prevDayClose;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 26, 2018 9:33 am
0

Thank you! I have just added it as a dynamic watchlist and set it up to get alerts. I will let you know if it doesn’t work.

( at October 26, 2018 12:48 pm)
0
Pete, I was trying out this code you made for someone else but I did not get any results. I tried the scan for close crossing above previous day high. I have the aggregation period set to 5 Min in the thinkScript Editor. Did I miss something? def newDay = GetDay() GetDay()[1]; rec highOfDay = if newDay then high else if high > highOfDay[1] then high else highOfDay[1]; rec prevDayHigh = if newDay then highOfDay[1] else prevDayHigh[1]; rec prevDayClose = if newDay[-1] then close else prevDayClose[1]; plot scan = close prevDayHigh;
( at October 26, 2018 5:24 pm)
0

My apologies. After seeing your comment I looked at the code and immediately found an error. I just updated the code in my answer and this version should work.

( at October 26, 2018 6:49 pm)
0

Pete, I think the new code did not attach.

( at October 27, 2018 1:12 pm)
0

I did not attach any code to my last comment. I updated the code that is contained in my answer.

( at October 27, 2018 4:42 pm)
0

Hi Pete…
Scanner doesn’t output any results. My scanner simply has below lines of code without any other standard filters.

def newDay = GetDay() GetDay()[1];
rec highOfDay = if newDay then high else if high > highOfDay[1] then high else highOfDay[1];
rec prevDayHigh = if newDay then highOfDay[1] else prevDayHigh[1];
rec prevDayClose = if newDay[-1] then close else prevDayClose[1];
# use this to scan for close crossing above previous day high
#plot scan = close[1] prevDayHigh;
# use this to scan for close crossing above previoud day close
plot scan = close[1] prevDayClose;

( at October 29, 2018 9:59 am)
0

I set this up for myself and it is returning results on a 5 min time frame. I have no idea why it is not working for you. What time frame do you have the scan set to?

( at October 29, 2018 10:46 am)
0

I set it up on 5 min time frame..

( at October 29, 2018 11:35 am)
0

Pete..I apologize..I had some other parameters that was restricting the scan results. It is working fine..

Thank you much! Truly appreciate your help..

( at October 29, 2018 11:45 am)