After making the corrections shown below everything is fine.

I used loop() for the advise calls as Spirit suggested. Though I'm not sure it's necessary, it is obviously better code. The main thing though was that I needed to explicitly call asset() in the for(listed_assets) loop:


vars cross_section;

/// m-period simple return, at t steps back in time
var simple_returns(int t, int m) {
return priceClose(t) / priceClose(t + m) - 1;
}

/// cross-section median of m-period simple returns, at s steps ahead
var median_cross_section_returns(int s, int m) {
int i = 0;
string current = Asset; // save the current asset
for(listed_assets) {
asset(Asset);
cross_section[i++] = simple_returns(-s, m);
}
asset(current); // restore the current asset

return Median(cross_section, NumAssetsListed);
}

function run()
{
StartDate = 19900101;
EndDate = 19931231;
BarPeriod = 1440;
LookBack = 240;

NumWFOCycles = 1;
DataSplit = 75;

set(RULES+PEEK);
Spread = RollLong = RollShort = Commission = Slippage = 0;
LifeTime = 1;
if(Train) Hedge = 2;

char* symbol;
while(asset(symbol = loop(Assets))) {
adviseLong(SIGNALS, median_cross_section_returns(1, 1), simple_returns(0, 1), simple_returns(1, 1), simple_returns(2, 1));
enterLong();
}
}

function main()
{
assetList("Assets.2.1993.csv");
cross_section = malloc(NumAssetsListed * sizeof(var));
}