Restructuring options for "2 pass" scan

Before spending too much time going in one direction, I'm looking for opinions/input on how I might do this.

Problem: current scan creates a bunch of symbols via AddToComposite. Later, in other code, percentages are calculated from a number of those. e.g., percent of stocks at new highs.

I would like to change this, so that the second calculation (percent at highs) is also done via the scan. Problem is this can't be done until all the symbols have been processed, and there's no way (that I can see) to know that when running a scan.

Options for solving:

  1. create a second scan, and just run that after the first one.

  2. run the scan in backtest mode, and see about using the custom backtest interface to do the second set of calculations at the very end (not sure if this is possible, seems like it might be)

  3. change the scan to explicitly read in all the symbols in a loop and process one at a time, and then do the second set of calculations. Seems like this would be slow. But maybe could be combined with changing to use StaticVars instead to offset.

  4. other possibilities???


Another possibility would be using the Batch window:

The Batch window introduced in version 6.20 (first time actually in 6.17.0 BETA) allows the user to automate mundane repetitive tasks by providing batch processing.

Now the user can easily define and automatically run sequences of Analysis operations such as scan, exploration, backtest and optimization and file export. Previously such automation was available only for programmers by means of OLE automation. Now it is available to everyone via easy-to-use interface.

1 Like

yes, that might be the most straightforward solution. Can do the first scan as now, create the second one that just runs once (not on all symbols), and run them as a sequence.