Help with ZScore

Wondering if someone here can help me out with this? I’m trying to create a rule to find stocks that are more than 1.5 standard deviations its mean to the index over the last 20 days. The screen below is how it’s designed in a filter in StockFetcher. I’m looking for any stocks where ZSCORE20 > 1.5. Can this same calculation be done in a rule in P123?

/FIRST DETERMINE HISTORICAL RATIO OF S&P STOCK TO THE SPY OVER THE LAST 20 DAYS/
SET{PRICERATIO, CLOSE / IND(^SPX,CLOSE)}
SET{RATIOMA20, CMA(PRICERATIO,20)} /* CMA is custom moving average */
SET{RATIOSTD20, CSTDDEV(PRICERATIO,20)} /*CSTDDEV is custom standard deviation */
SET{DIFF20, PRICERATIO - RATIOMA20}
SET{ZSCORE20, DIFF20 / RATIOSTD20}

Obrigado!

Tony

Tony x3 - you can do this by first setting up 20 custom formulas. The first 5 are shown below.

Then use the following rule:

b/StdDev($A1,$A2,$A3,$A4,$A5)>1.5[/b]

Again the rule was written for 5 bars. You will have to expand it to 20.

Take care
Steve


CustomFormulas.gif