Would appreciate if someone could look at this code snipped and see what I may be doing wrong. I'm trying to loop thru a dataset and calculate the relative strength (RS) for each symbol in the list based on it's 126 SMA. The problem comes in for stocks that have less than 126 days. For some reason, Bars.Count always evaluates to the number of bars in the datapane (even after SetContext), so I am unable to skip those stocks. Further, somehow it calculates an erroneous SMA for those stocks. Any ideas ? Is there a better way to do this ? thx
CODE:
Please log in to see this code.
Size:
Color:
SetContext(DataSetSymbols[ds],true);
The "true" means that you're synching the symbol raw data to the primary series. (See the WealthScript Programming Guide: DataSeries > Accessing Secondary Symbols > Secondary Series Synchronization)
So, the answer is to calculate your RSs using the symbols' raw data (i.e., before synch) and then use the Synchronize command to synch the series to the chart.
Size:
Color:
thx Cone.
Size:
Color: