Since your request specifies the first two hourly bars of the trading day I will provide a very simplistic solution. You only need to check if the current bar is a different day than the previous bar. When that is true we know we have the first bar of the new day.
def newDay = GetDay() <> GetDay()[1];
This gives us a True/False variable that tells us when we are on the first bar of a new day. This requires us to uncheck the box for Extended Trading Hours. So we are only working with Regular Market Hours.
Next, we use this True/False variable in a plot statement in a way to evaluates to True for the first two bars of the trading day.
plot scan = newDay and newDay[1];
That’s it. Place both of these lines together in a new study filter applied to the hourly time frame, unchecking the box to turn off Extended Hours. You don’t have to add these lines to the original code. Just add it as a new Study Filter and it will work in combination with all the other filters in your scan.
had an issue with the code
I entered it by itself in its own study and also with in this and other studies
input xPercent = 10.0;
def percentChange = 100 * (close / close[1] – 1);
def newDay = GetDay() GetDay[1];
plot data = AbsValue(percentChange) > xPercent;
Getting Red Highlight on the second GetDay
Expected double
No such variable: GetDay at 3:26″
Yes, sorry. The second one is missing the parenthesis. Sorry, did this from memory and did not test it. I just updated my answer to correct the typo so future visitors will not be tripped up. Thanks.