Close of current 5 min crosses above yesterday’s close for the first time


Category:
0
0

Hello,

I already have a scanner (code below) provided by Pete but I would like to enhance it  adding two scenarios below.

Scenario 1: Output only those symbols that close of current 5 min bar crosses above yesterday’s close for the first time.

Scenario 2: Output results where today’s high never crossed above previous day close yet within previous 5 min bar and crossover happens at the next 5 min bar.

Please see screenshot for details.

 

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 previoud day close
plot scan = close[1] <= prevDayClose and close > prevDayClose;

Attachments:
Marked as spam
Posted by (Questions: 7, Answers: 8)
Asked on October 30, 2018 10:48 am
119 views
0
Private answer

Whenever referencing code from a previous source it’s always best to include a link to that source. Even when it is a post in our Q&A forum. This helps the rest of our audience to have access to the full context of the code you are presenting. https://www.hahn-tech.com/ans/scan-close-of-5-min-bar-crosses-above-yesterdays-close-or-high/

The following contains a couple of extra lines that should account for the additional specifications. I have not tested this.

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];
def crossing = close[1] <= prevDayClose and close > prevDayClose;
rec hasCrossed = if newDay then 0 else if crossing then 1 else hasCrossed[1];
plot scan = !hasCrossed[1] and crossing;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 30, 2018 11:37 am