Exclude previous day conditions from intraday scan

luicius

New member
I have a scanner that looks for 3 green bars with higher highs and higher lows intraday.

Code:
def startTime = SecondsTillTime(0945) >= 0;
def endTime = SecondsFromTime(1545) >= 0;
def timeEnabled = !(startTime or endTime);

def greenCandle = close > open;

def higherHighs =
    high > high[1] and
    low > low[1] and
    high[1] > high[2] and
    low[1] > low[2];

plot scan = timeEnabled and
    ((greenCandle[3] and greenCandle[2] and greenCandle[1])
    or (greenCandle[4] and greenCandle[3] and greenCandle[2])
    or (greenCandle[5] and greenCandle[4] and greenCandle[3])
    or (greenCandle[6] and greenCandle[5] and greenCandle[4]))
    and (higherHighs or higherHighs[1] or higherHighs[2]);

The issue I am having is that the scanner produces results for stocks that have 2 green bars in a row with higher highs and higher lows during the current trading session and would also include a green bar with higher highs and higher lows from the previous day. Please advise on how to exclude previous day conditions so that my scan will only produce results for condition met during the current trading session?

2n8aEoh.png
 

XeoNoX

Well-known member
VIP
try this

Code:
def day = GetDay();
def lastDay = GetLastDay();
def isToday = If(day == lastDay, 1, 0);

def startTime = SecondsTillTime(0945) >= 0;
def endTime = SecondsFromTime(1545) >= 0;
def timeEnabled = !(startTime or endTime);

def greenCandle = close > open;

def higherHighs =
    high > high[1] and
    low > low[1] and
    high[1] > high[2] and
    low[1] > low[2];

plot scan = isToday and timeEnabled and
    ((greenCandle[3] and greenCandle[2] and greenCandle[1])
    or (greenCandle[4] and greenCandle[3] and greenCandle[2])
    or (greenCandle[5] and greenCandle[4] and greenCandle[3])
    or (greenCandle[6] and greenCandle[5] and greenCandle[4]))
    and (higherHighs or higherHighs[1] or higherHighs[2]);

###XeoNoX### Appreciation goes a long way in life... Don't forget to hit the like button if you liked my post!
 
Last edited:

luicius

New member
try this

Code:
def day = GetDay();
def lastDay = GetLastDay();
def isToday = If(day == lastDay, 1, 0);

def startTime = SecondsTillTime(0945) >= 0;
def endTime = SecondsFromTime(1545) >= 0;
def timeEnabled = !(startTime or endTime);

def greenCandle = close > open;

def higherHighs =
    high > high[1] and
    low > low[1] and
    high[1] > high[2] and
    low[1] > low[2];

plot scan = isToday and timeEnabled and
    ((greenCandle[3] and greenCandle[2] and greenCandle[1])
    or (greenCandle[4] and greenCandle[3] and greenCandle[2])
    or (greenCandle[5] and greenCandle[4] and greenCandle[3])
    or (greenCandle[6] and greenCandle[5] and greenCandle[4]))
    and (higherHighs or higherHighs[1] or higherHighs[2]);

###XeoNoX### Appreciation goes a long way in life... Don't forget to hit the like button if you liked my post!
Thank you so much for this. I will report back
 

Similar threads

Top