Scan for three equal hourly highs in a day


Category:
0
0

TOS, 7 bars in a day. I would like to scan 8 bars from the first bar of the day to the first bar of the next day wherein the high of bars 1,7 & 8 match and/or the high of bars 1,6 & 8 match. Red or Green candles do not matter, only the highs. Example attached. I hope this makes sense?

Thank you

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on May 11, 2020 11:39 am
82 views
0
Private answer

First, everyone that posts in the Q&A forum needs to make sure any chart screenshots they include contain the full view of the chart. You may think you have done good buy cropping the image to focus on the details important to you. However unless your screenshot includes the full view of the chart we cannot see all the details required to replicate that chart on our side, which is the very first and crucial step to formulating a solution. So don't force us to examine an elephant through pinhole, or important details will be lost.

Second, since your scan will always be run on the hourly time frame and will always be run during the first hour of the day, the solution is very simple. Could be much more complex, but so long as you stick with your plan it work. Try running this scan at any other time of the day and it will not. Keep this in mind: Because you run this scan during the first hourly bar of the day, the high of that bar is still not determined. The scan be return a true result for stock that is latter invalidated if that first hourly bar makes a new high before it closes.

To solve this we use index numbers. [0] == current bar, [1] == previous bar, [2] == the bar before the previous bar... and so on.

Here is the code:

# bar 1 is [7], bar 7 is [1] and bar 8 is [0]
def patternOne = high[7] == high[1] and high[1] == high[0];
# bar 1 is [7], bar 6 is [2] and bar 8 is [0]
def patternTwo = high[7] == high[2] and high[2] == high[0];
plot scan = patternOne or patternTwo;

Now, I know there are times when you will want to run this scan during the second hour of the day, because that is the only way you know the pattern is complete and not subject to change. So if you want to scan during the second hourly bar of the day you will modify the last line of code as follows:

plot scan = patternOne[1] or patternTwo[1];

Final note, this code also requires you uncheck the box named "EXT", so that the scan does not include extended hours.

Marked as spam
Posted by (Questions: 37, Answers: 4108)
Answered on May 11, 2020 3:40 pm