Iterate all matching symbols in apply-to filter settings

Is there a way to programmatically fetch the list of all matching symbols in the apply-to settings? The reason I need this is to iterate the symbols for some pre-processing during phase 1 backtest, stocknum 0.

I know this can be done easily when there is a single watchlist, but as shown in the image below, there could be multiple watchlists, on both the include and exclude tabs.

Any ideas?

image

First and foremost, iteration through all "Apply to" symbols is automatic when you use Analysis window. You don't need any code for that. You probably know that but I am writing this for the others so they don't follow that route.

To answer directly your question you can use CategoryGetSymbols together with GetOption. Multiple selections need to be combined on your own in the formula.

Generally you should avoid doing pre-processing in stocknum==0 because it is slower and can't run multiple threads.

If you need extensive pre-processing use seprate scan for that. You can sequence scan and later backtest using batch window. You don't need any code for that. A single formula could handle both

if( Status("action") == actionScan )
{
   // do the pre-processing
}
else
{
  // do normal processing
}

In the batch window use: LoadProject, Scan and Backtest commands. A single project file would handle that.

@Tomasz Thank you for the prompt reply on the weekend. May I ask, does the Scan operation enforce pad-and-align in the same way as backtest?

Yes, pad and align works for every mode including Scan.

Thank you @Tomasz. I have something working now.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.