#### Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

# Performance Relative to an Index

I want to set up a scan that looks at when the ratio of a stock price vs \$SPX crosses above the 12DEMA of the ratio. Basically trying to capture which stocks start outperforming \$SPX over a 12D lookback period.
For example, AAPL:\$SPX x EMA(12, AAPL:\$SPX).

However, I believe ratios are not allowed in scans. Best alternative is probably PctRelative.
I have tried several different values of a and b parameters in PctRelative(a,\$SPX) x EMA(b, PctRelative(a,\$SPX)). Can't get the same results as the ratio when i look at the charts of stocks from the scan results. I want the crossing point to be captured by the scan but i get it either before or after.

Can the correct parameters be mathematically derived? If there is a way, it would give me flexibility to try other lookback periods without a lot of trial and error for each lookback period.

• mod
The ratio line calculation ( price x divided by price y at each bar) and the PctRelative calculation (x2 - x1)/(y2-y1) are not the same calculation, so the result will always be different. Similar sometimes, but different. Unfortunately, as far as I know, you can't plot PctRelative on the chart, so you can't verify your results with the precision you probably want.

I think I've recommended this before: put \$SPX in your list(s) and rank the list by your choice of performance measurement. Symbols appearing above \$SPX are outperforming. If you save the results to CSV files daily, you can compare, day by day, which symbols are moving up and down, including, which are crossing above or below \$SPX. More work, but might be worth it.
• ✭✭
Or use a rank by against your scan results. Put the Rank by as the last line of your scan.

Rank By [PctRelative(12,\$spx)] // is probably a good bet.

As to your original question, I've never had it work using the MA. A multiplier might work like PctRelative > 21 days ago PctRelative * 1.12 but still not exactly what you are looking for.

Creating a list with the Relation symbols of interest might also be of value to you. This list can be viewed in Summary view to see how it's changed over time. Also you can use that list in scans as you see fit. So your list would have the AAPL:\$SPX, GOOG:\$SPX, etc. or whatever relationship you would like to view.
• I tried a few things but u r right. It won't work the same way. Does work in thinkorswim. I wonder why stockcharts won't implement it in scan but allows charting of a ratio.
• ✭✭
Is that the RSMK indicator on TOS?