Creating a Custom Market Breadth Indicator Help

Hey guys, hope everyone had a good Christmas and New Year.

I'm trying to create some market breath based indicators and am curious to see how it correlates to the market/ act as a potential timing model etc.

For example, %stocks in the S&P500 above the 200dma is a common breadth indicator.

if I wanted to create something similar and add in some other variables such as.

  • % stocks " " above the 50d moving &
  • % stocks " " above the 20d moving

as what would be the % of stocks in sp500 if all 3 conditions held true - what would be best way to go about it?

I've thought about going about it via backtest. In which when all those conditions are true = buy and when not = sell. Run it against the SP500 and export the data. tally up the sum of true results/trade would be held for a given day in a column then re-upload that data.

However, I'm hoping their be an easier way/ an AFL function that refers/runs against everything in a watchlist but I'm not sure what exactly it might be.

I know of foreign() function but would like to refer to all stocks instead of just one ticker

Any thoughts would be appreciated and a huge help.

Thanks Guys


@BradSyn I suggest to review this past thread, since, AFAIU what your are looking for, seems a good candidate for the AddToComposite() function or similar approaches.


Norgate Premium Data has about every breadth indicator you can imagine and what you desire would be easily accomplished by a few simple foreign statements.


Awesome, thankyou for the share to the thread. I haven't used that function before, so will look into how to do so.

Much appreciated,


1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.