Analyst Upgrades indicator
Author: kbellare
Creation Date: 7/11/2014 8:14 PM
profile picture


I'm looking to code an indicator -
"Avg. analyst rating today - Avg analyst rating 5 days ago", filter stocks that have at least 4 analyst ratings.

I used the code below, but it seems to calculate something different - it determines -
"Average(of last 4 upgrades/downgrades that were made)[today] - Avg(last 4 upgrades/downgrades that were made)[1 week ago]" -> This has 2 problems
1) Note that analyst ratings that were not changed are not considered in this formula.
2) Also, 2 of the 4 recent upgrades/downgrades may have happened 3 months ago, but this formula still picks it up.

How do i code the indicator that i need (first one described above)?

Please log in to see this code.
profile picture


I guess the answer is not that easy. Your understanding of how FundamentalDataSeries works is correct, and you have to code your logic from the ground up using the FundamentalDataItems collection of analyst ratings. Loop through it, compare the bar date to the fundamental item's .Date property, query the .Value, sum, average etc.

Below is a good example to start out with your own programming:

Backtest Analyst Ratings > post #4
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).