help: percentage stocks above sp500

I want to try a simple hedge: stop trading if a percentage of stocks are below the sp500 and vice versa. how do I go about it?

thanks mucho.

First, need to know how you want to define “below the sp500”. Relative price return over last X days, or something else?

let’s take an example. 200d moving average of the sp500. then let’s take as a trigger when 65% of stocks drop below the sp500.

I can then try different setups from this.

of course, am fully open to other triggers you may have had better luck with.

tnx

  1. Create a custom series, using the formula 100*UnivCnt(“(close(0)-SMA(200))>0”)/UnivCnt(“close(0)>0”), and save the series as %below200SMA

  2. Use custom series, for example GetSeries(“%below200SMA”)<35, as sell hedge rule, in screener or simulation. Make sure you create a corresponding buy rule to exit the hedge.

Hope this helps.

Thanks joe,

I understand the hedge rule, but I don’t understand the custom series. how is this related to the sp500 or for example if I want to use the nasdaq or any other index?

Thanks for a short explanation so I can take it from there. :slight_smile:

That series gives you the pct of stocks above 200SMA, not below the 200SMA.

In the TOOLS >Custom Series page you must select the appropriate universe you want to use. It is the box left of the benchmark box.

Right, so I can use a universe like All Stocks USA, but I don’t see how this calculates the 200day ma of the sp500 (or for clarity’s sake let’s say Nasdaq 100) as the threshold.

So, I thought we had to first calculate the 200day ma of the Nasdaq 100 index. Then test to see based on a universe, lets say the All Stocks USA, how many are above or below. And then create a hedge rule to enter or exit based on how many I want above or below this custom series.

I think I’m starting to see a pattern.

This solution presented here is self-serving. The universe describes both the number of stocks and the sma.

What I think I need to do is create a custom series with just the sma of a ‘benchmark’. Then use that custom series in a second custom series to calculate the number of stocks above or below.

Is it possible to call the function sma() of an index inside a custom series to simplify things?

You need to create a custom series for each universe, for example S&P500, All Fundamentals, etc.

Please see below screenshot of my Russell 2000 custom series. Change the “Universe” (yellow outline) as per your requirements.

My custom series returns for its universe the percentage of stocks above the 200 SMA.

In your screener/simulation hedge rules, please refer to your custom series as described above.


Yeah joe, I see what you mean.

Merci so very much.

To take it one step further, I wanted to see a smooth curve of these results.

However, the logic of adding SMA(50,0,100*UnivCnt(“(close(0)-SMA(200))>0”)/UnivCnt(“close(0)>0”) ) for example doesn’t work.

How can I do this?

SMA(50, 0, GetSeries(“%Above200SMA”))

Ahhh!!!

Thanks joe for your infinite patience.

I’m getting the same error as when I was doing it.

When I run it as a new custom series I get that SMA doesn’t work.


You are not using the stock/etf screener, but the custom series form.

With regard to the Portfolio123.com menu bar, go to “Screen”, “Screen” and create a new stock screen. Then try your rules again.

Please have a look at the screenshot of my screen. The tabs at the top of the stock/ETF screen are different.

You do not need “ShowVar” (I just wanted to check it really works).