252 day EMA trending up script

I need help scripting for 252 day EMA trending up for at least 1 month. I’m trying to scan for stocks that have 252 day EMA trending up for at least 1 month, but I do not know how to code for it.

Hi Yi Jun,

You can use the IsUp and BARSTRUE functions to show when the condition has been true for 22 trading days (about a month):

V1 = MA(BARS=252, STYLE=Exponential, CALC=Close) IsUp; 
BARSTRUE(V1, LOOKBACK=22)==22

Here’s another option using the Linear Regression Slope tool, which is a little more forgiving if there’s a small blip in the EMA direction, but the overall trend is up over the last 22 days:

V1 = MA(BARS=252, STYLE=Exponential, CALC=Close);
//Is the slope of the MA positive over the BARS period?;
LRSLOPE(V1, BARS=22) > 0