Number of stocks above moving average in backtest

Hello,

I would like to create a backtest that buys SPY when % of stocks in the S&P500 are above their 200 day moving average and sell when not.

I found this thread that shows how to make an indicator but have no clue how I can implement it for backtesting:

Any help would be appreciated.

Tutorial is must-read for newbies:
http://www.amibroker.com/guide/a_addtocomposite.html

So its not possible then?

Did you read the article? It is possible and explained in the article.

1 Like

Jup, but the example is using scan. I want to be able to use it in a backtest.

Re-read the article. It explains everything.
You run a scan first to create composite (this is done ONCE). THEN you can run backtest or anything else and refer to composite using Foreign() call.

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