Multi Symbol Backtest "Backtest on all Symbols"
Author: hlh
Creation Date: 3/31/2011 3:38 PM
profile picture

hlh

#1
Questions about Multi Symbol Backtest "Backtest on all Symbols"

As I assume to generate signals over whole Datasets in Strategy Monitor it is required to let WL loop thru it like clicking on "Backtest on all Symbols", and as there anyway seems to be a "slowing down" bug in WL6 using SetContext() to manually loop thru a Dataset (while clicking a single symbol) I would have some basic questions I did not find in the forum or Wiki:

My scripts do some tests "first" to make sure reliable data is being generated, like
CODE:
Please log in to see this code.

Running it over S&P500 would make me click 500 times "OK" on the message window. I assume/hope there is a way to not only cancel the script over the current symbol but stopping WL in "Multi Symbol Backtest" completely?

Despite being "required" (see remark on top) to use "Multi Symbol Backtest", I still would require to loop thru all the symbols getting the last bar date: So implementing a loop like
CODE:
Please log in to see this code.

is not only not elegant, but slows my execution down significantly (as this loop of 500 symbols is run 500 times in "Multi Symbol Backtest" mode = 250,000 operations).
So can I set a global variable or something which when the executions starts with the very first symbol that the loop is only executed once? Would be nice, but how could I refresh and rerun this again when in Strategy Monitor and a new bar update was done?
Also, when I run it only once on the first symbol, I still would require to hold the information gathered, like what is now done in my lists like 'lastDateOKList'?
And to make things worse, I would need to have 3 or more times this script open in Strategy Monitor, running over different Datasets - would this cause trouble with global variables (or whatever I could use to solve the above requirements)?

Same or similar to the problematic above is, that I write data to files at the end of the script. Again, I would prefer to store my results - still executed in "Multi Symbol Backtest" mode - in a List or Directory or something and only write to a file once. So the opposite to me looping thru all the last bar dates at the beginning, now I would like to store data and then recogniz in the code when WL has finished or is finishing with the last symbol of the Dataset.

Thank you!
profile picture

Cone

#2
QUOTE:
I assume/hope there is a way to not only cancel the script over the current symbol but stopping WL in "Multi Symbol Backtest" completely?
Escape key [Esc] does it in single symbol mode; in MSB the Cancel button is the method.

QUOTE:
So can I set a global variable or something which when the executions starts with the very first symbol that the loop is only executed once?
Just check that the script is operating on the first symbol in the dataset -
CODE:
Please log in to see this code.


QUOTE:
Also, when I run it only once on the first symbol, I still would require to hold the information gathered, like what is now done in my lists like 'lastDateOKList'?
See above; you can store the information in the strategy's class-level variables to use them for each subsequent run.

I think with these answers, you have the answers to the rest of the questions too.
profile picture

hlh

#3
Yes, that did solve it. Thank you!
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).