Hello dear all.
I am having a hard time understanding my issue. within a EOD Backtest i am trying to find the percentage of stocks that Closed Green for the current day within an Watchlist. For this i use the following code
wlnum = GetOption( "FilterIncludeWatchlist" );
List = CategoryGetSymbols( categoryWatchlist, wlnum );
NoM = StrCount( List, "," );
Up = 0;
Total = 0;
for ( i = 0; ( symbol = StrExtract( List, i ) ) != ""; i++ )
{
SetForeign ( symbol );
Up = IIf( Close / Open > 1, Up ++, Up );
RestorePriceArrays();
}
PercentWatchlistUp = round ( 100 * ( Up / NoM ) );
Plot( PercentWatchlistUp, "UP", ColorRed, StyleLine );
It does give me the wanted results, but starts plotting the Value's to late. Within my Watchlist (S&P 500 stocks) it starts giving me usefull
Data in June this Year (see Image Below).
I Presume this is because that day will be the very first day that Data is available for
ALL stocks together at the same time ?
And most likely this part of the code is checking if the Ticker is not empty and makes sure it does not set Foreign to a empty Ticker ?
( symbol = StrExtract( List, i ) ) **!= ""**
What i would like is to include the (not yet) existing stocks in the Watchlist and keep track of the amount "Useable" stocks and ignore the empty ones (Array Total reserved for this in script) and include them in the calculation.
For example if Stock X and Y where the only ones available in the year 1985, i would like to
have that number (2 for 2 stocks) even the next Stocks data would start 3 Years later.
Is this doable, if so could someone be so kind and push me in the right direction ?