Hello,
I have some problems when backtesting a large number of symbols for a wide range of years. As an example, please consider the following system:
SetOption("CommissionAmount", 0.00);
SetOption("InitialEquity", 10000);
SetOption("MaxOpenshort", 0 );
SetOption("MaxOpenLong", 5);
SetOption("MaxOpenPositions", 5);
SetOption("WorstRankHeld", 5);
SetOption("AllowPositionShrinking", True);
SetPositionSize(20, spsPercentOfEquity);
SetTradeDelays(0, 0, 0, 0);
SetOption("HoldMinBars", 1);
SetBacktestMode(backtestRegular);
RoundLotSize = 1;
BuyPrice = Close;
SellPrice = Close;
WLNUMBER = GetOption("FilterIncludeWatchlist");
LIST = CategoryGetSymbols(categoryWatchlist, WLNUMBER) ;
if (Status("Stocknum") == 0 )
{
StaticVarRemove("VALUE_CLENOW_US*" );
for (n = 0;(SYMBOL = StrExtract(LIST, n)) != ""; n++)
{
SetForeign (SYMBOL);
SLOPE = (exp(LinRegSlope(ln(C), 20))^52) - 1;
RSQ = (Correlation(Cum(1), C, 20))^2;
SCORE = Max(0,SLOPE * RSQ);
RestorePriceArrays();
StaticVarSet ("VALUE_CLENOW_US" + SYMBOL, SCORE);
}
StaticVarGenerateRanks("RANK","VALUE_CLENOW_US", 0, 1224);
}
VALUE = StaticVarGet ("VALUE_CLENOW_US" + Name());
RANK = StaticVarGet ("RANKVALUE_CLENOW_US" + Name());
Buy = RANK < 5;
Sell = RANK >= 6;
PositionScore = VALUE;
It works properly for 10 symbols from 1996 to 2017, as shown in the following image:
However, it does not work properly for 100 symbols (including the previous 10 symbols) from 1996 to 2017, it is not until 2005 that the systems starts to trade.
What is the problem? Is there any limit to the number of static variables stored? How could I have it solved?
Thank you in advance for your help.