I'm running an ORB Scanner I found online and modified it to show instances of clean breaks above the 15-minute opening range (OR). I want to take it a step further and ONLY display green bars that also have a low that crosses into the ORB. See below for an example of what I'm looking for:
The fourth bar in $AAPL has a low that crosses below the 15-minute opening range, an open above the opening range, and a close above the open.
I tried to modify the code below by changing the plot conditions and had some success as I'm seeing bars where the low crosses into the OR but I'm having difficulty making it scan for only green bars. I'm still seeing a mix of red bars where technically the open and close are both above the OR. I tried using "open < close" and "isAscending(close, 1)" but both are filtering out $AAPL which I'm using to validate the scanners effectiveness. The formation is pretty clear in $AAPL on the 15 minute timeframe so I'm not sure why this is happening. See below for the code I'm using.
Code:
def orStartTime = 0930;
def orEndTime = 0945;
# opening range time logic
def isOr = secondstilltime(orEndTime) > 0
and secondsfromtime(orStartTime) >= 0;
def afterOR = secondsFromTime(orEndTime) >= 0;
def hi = high;
def lo = low;
# opening range levels logic
rec orhi =
if orhi[1] == 0
or !isOr[1]
and isOr
then hi
else if isOr
and hi > orhi[1]
then hi
else orhi[1];
rec orlo =
if orlo[1] == 0
or !isOr[1]
and isOr
then lo
else if isOr
and lo < orlo[1]
then lo
else orlo[1];
plot orb = afterOR and low < ORHI and open > ORHI and close > ORHI;