StaticVarGenerateRanks loop have only data by first symbol

Hi,

I've encountered the issue that the first symbol in the back test dictates what the data range will be for the StaticVarGenerateRanks loop.
According to multiple threads on this forum the way to solve it is to use pad and align and select a symbol whose data has the date range of the analysis. However, it didn't do anything. Trying the other way; selecting a symbol with a shorter data period then the first symbol does shorten the range of the data as expected, so it's not like pad and align doesn't work.

Any suggestion will be greatly appreciated.

That is the correct solution. If you post your code, people will be able to find your error more easily.

I used the simplest code I could, still got that problem:

wlnum = GetOption( "FilterIncludeWatchlist" ); 
List = CategoryGetSymbols( categoryWatchlist, wlnum ) ;
SetOption("MaxOpenPositions", 3);
 
if ( Status("stocknum") == 0 ) // Generate ranking when we are on the very first symbol
{
     StaticVarRemove( "values*" );

     for ( n = 0; ( Symbol = StrExtract( List, n ) )  != "";  n++    )
     {
         SetForeign ( symbol );
        
         // value used for scoring
         values = 1;
         RestorePriceArrays();
         StaticVarSet (  "values"  +  symbol, values );
         _TRACE( symbol );
     }

     StaticVarGenerateRanks( "rank", "values", 0, 1224 );
}

symbol = Name();
values = StaticVarGet ( "values" +  symbol );
rank = StaticVarGet ( "rankvalues" +  symbol );

Buy = rank <= 3;
Sell = 1;

Settings:

pad%20settings

I use Norgate data. Thanks.

Two things:

  1. Why are you using a constant value of 1 for your ranking? This means all symbols will have the same rank.
  2. How do you know your results are being truncated? Have you written exploration code? Run a scan?

Hi Matt,

  1. This code is just to test the problem, so I tried to make it as simple as possible. The issue happens regardless of what ranking method I use.
  2. When I turn on pad and align I get correct results from Explorer for the cut dates (when it's off I don't get any results), but the backtest results are still the same (only data range of the first symbol).

What about a Scan, which shows all your entry and exit signals with no additional work on your part?

It would help if you would post your complete code so we can see exactly what you're doing.

Hi Matt,
You were right, trying to simplify the code only caused other issues. The problem is my original code was using TimeFrameSet(inWeekly) inside the symbols loop, dropping it fixed the problem. I'll leave it out for now.

Thanks for your patience and help.

TimeFrameSet() just changes the built-in variables. Any variables that you assigned inside the TimeFrameSet() / TimeFrameRestore() block (like your ranking values) would typically be expanded individually with TimeFrameExpand().