Scanner to paint signals only after market closed

Nick

Active member
2019 Donor
VIP
Hi, I need some assistance with this indicator script and the scanner that i am trying to create. To set the context, i am trading on Daily Timeframe and i will use this script to find trade signals after market close to prepare the next day trade. So, any Signals painted during market hours are not tradable yet.

I have created a scanner with the script and it is able to scan out stocks that met the criteria "is True within 2 Bars" and displayed in the dynamic watchlist. As such, it will scan SIGNALs for Current Day and Yesterday to be appeared in the watchlist

The questions i have are

1. Is there a way that the dynamic watchlist DO NOT update the CURRENT day signals and only UPDATE it after market closed?

2. Or Is there a way that the CURRENT day SIGNALS can only be painted after Market has closed.

Thank you

Code:
##############################################################################
# Plot EMA Trends

plot Trend1 = MovAvgExponential(close, 20);
Trend1.AssignValueColor(if close > Trend1 then Color.GREEN else Color.RED);

plot Trend2 = MovAvgExponential(close, 40);
Trend2.AssignValueColor(if close > Trend2 then Color.GREEN else Color.RED);

def Price2MA = MovAvgExponential(close, 10);
def condition1 = close > Price2MA;

input length = 14;
input over_sold = -100;
input over_bought = 100;
def price = close + low + high;
def linDev = LinDev(price, length);
def CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
def ZeroLine = 0;
def condition2 = CCI crosses above ZeroLine;

plot Signal1 = condition1 and condition2 and Trend1 > Trend2;
Signal1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Signal1.SetLineWeight(3);
Signal1.AssignValueColor(Color.MAGENTA);

#End

The last signal arrow was painted when the market is still open.

nFBEbpU.jpg
 

rad14733

Well-known member
VIP
@Nick I think @BenTen's method would probably work best... The only alternative would be to use a time constraint as part of your criteria that would exclude the currently active trading session... And if something shows up today of course it will also show up tomorrow so why the delay...???
 

Nick

Active member
2019 Donor
VIP
@rad14733 thanks for your response. May i know how can i add the time constraints to exclude currently active session? Oh, i missed to explain this part, that one of the rules i have for trade entry is to have a GREEN EMA following a valid signal. That's why i only focus on the previous day signal.

Thanks
 

XeoNoX

Well-known member
VIP
Be sure to include extended hours on your scan and the proper time aggregation.

Code:
def Trend1 = MovAvgExponential(close, 20);
def Trend2 = MovAvgExponential(close, 40);
def Price2MA = MovAvgExponential(close, 10);
def condition1 = close > Price2MA;
def length = 14;
def over_sold = -100;
def over_bought = 100;
def price = close + low + high;
def linDev = LinDev(price, length);
def CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
def ZeroLine = 0;
def condition2 = CCI crosses above ZeroLine;
def Signal1 = condition1 and condition2 and Trend1 > Trend2;
def Signal1_Aftermarket= if getday()==getlastDay() and secondsfromTime(1200)>0 and secondsFromTime(1600)<0  then Signal1 else Signal1_Aftermarket[1];

plot scan = Signal1_Aftermarket;
 

Nick

Active member
2019 Donor
VIP
Be sure to include extended hours on your scan and the proper time aggregation.

Code:
def Trend1 = MovAvgExponential(close, 20);
def Trend2 = MovAvgExponential(close, 40);
def Price2MA = MovAvgExponential(close, 10);
def condition1 = close > Price2MA;
def length = 14;
def over_sold = -100;
def over_bought = 100;
def price = close + low + high;
def linDev = LinDev(price, length);
def CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
def ZeroLine = 0;
def condition2 = CCI crosses above ZeroLine;
def Signal1 = condition1 and condition2 and Trend1 > Trend2;
def Signal1_Aftermarket= if getday()==getlastDay() and secondsfromTime(1200)>0 and secondsFromTime(1600)<0  then Signal1 else Signal1_Aftermarket[1];

plot scan = Signal1_Aftermarket;

@XeoNoX I have followed your instruction to include the extended hours and time aggregation in my scan, can i confirm if this is correct?
Thanks
Scanner setup
 

Nick

Active member
2019 Donor
VIP
i beleive all you have to do is attemt to apply the code and then see if it works. :ROFLMAO:
Yes, i did produce some scan results but the results didn't meet the Signal1 conditions... 😅 😅
Secondly, I am not sure what is the right time aggregation to set and it's significance?
Hope to get some advices on this..thanks
 

XeoNoX

Well-known member
VIP
Yes, i did produce some scan results but the results didn't meet the Signal1 conditions... 😅 😅
Secondly, I am not sure what is the right time aggregation to set and it's significance?
Hope to get some advices on this..thanks
can you post screenshots of the way you are setting up the scanner and custom scan study and the results that you say arent meeting condition1?
 

Similar threads

Top