Alerts[i] access from different strategies
Author: BryanStanton
Creation Date: 12/25/2008 6:25 PM
profile picture

BryanStanton

#1
I'm interested in using the Alerts list as a filtered list. The approach that I want to use is to do the quick filtering of all equities in the data file to produce an initial list of qualified equities. Using this filtered list I can then do a more thorough testing.

However, it appears from what I've read in the help files and a bit of testing, that the only alerts available to a particular strategy are the ones produced by that strategy in that particular run. Does any one know if there is any way to access the whole alert list, regardless of what strategy produced it and when?

The only other option I can think of is saving the Alerts to a text file which is then accessible to any strategy. Is this the best option?

profile picture

Cone

#2
There are a few ways to do this. Here's a procedure for the Multi-Symbol Backtest method.

1. Check to see if today's Alerts have been created (see Step 3).
- If not, continue with Step 2.
- If so, skip to Step 4.

2. At the top of the Strategy, loop through the DataSetSymbols loop to generate the Alerts. Pass false to the SetContext synchronize parameter. See the examples of these functions in the QuickRef.

3. Save the Alerts to global memory or disk file. My preference is the latter, and that way you'll have a record for each day (use a file name with yyyyMMdd). You could even do both.

4. RestoreContext() and check the Alerts to determine if the current Symbol (Bars.Symbol) is in the list.
- If not, return()
- If it is, continue with the Strategy
profile picture

BryanStanton

#3
Thanks Cone for that quick reply.
It's taken me a little while to consider the code because I'm still learning the SetContext and RestoreContext() functions.

As I understand it, the SetContext is required because we are looping through the symbols using the DataSetSymbols array, which are different to the primary symbol. Then the RestoreContext() is required to ensure that the current (primary) symbol has reference (or context).

I like this approach. Thanks.