Herman,

To use Foreign, you need to know exactly which symbol you want to 
reference. Because the custom backtest is run only once, and does not 
have a current symbol, your function would only be called once and 
would be called only with the symbol provided in the call.

As such, you would probably want to alter the function definition to 
receive the array directly. This way, any array can be passed in 
without having a hard coded Foreign statement within the function 
itself.

e.g.

function Test(values) {
    return LastValue(values);
}

You would then code your custom backtest as follows:

if (Status("action") == actionPortfolio) {
  ...
  T = Test(Foreign("ORCL", "O"));  // Single foreign symbol.
  ...
}

If you are trying to have your function called for each symbol in your 
watchlist, you would have to add looping code to iterate through your 
watchlist and call Test for each symbol, using Foreign with each new 
symbol name as folllows:

if (Status("action") == actionPortfolio) {
  ...
  listnum = ... // Your watchlist
  list = CategoryGetSymbols(categoryWatchlist, listnum); 

  for (i = 0; (sym = StrExtract(list, i )) != ""; i++) { 
    T = Test(Foreign(sym, "O"); 
  } 
  ...
}

Does that help?

Mike

Reply via email to