When I set PEEK, and define a series that peeks ahead (for the target variable of course), then in some cases adviseLong with SIGNALS does not generate the signals file.

For example, in the following script (also attached) the median return one bar ahead over all assets is calculated in the variable cross_section_median. No signal files are output. However,
if I comment out the definition of cross_section_median then I get a signals file for each asset.

Is this a bug?


/// 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) {
vars cross_section = malloc(NumAssetsListed * sizeof(var));

int i = 0;
while(asset(loop(Assets))) {
cross_section[i++] = simple_returns(-s, m);
}

var result = Median(cross_section, NumAssetsListed);

free(cross_section);

return result;
}

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

NumWFOCycles = 1;
DataSplit = 75;

assetList("Assets.2.1993.csv");
set(RULES+PEEK);
Spread = RollLong = RollShort = Commission = Slippage = 0;
LifeTime = 1;
if(Train) Hedge = 2;

//vars next_return = series(simple_returns(-1, 1));
vars cross_section_median = series(median_cross_section_returns(1, 1));

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

Attached Files
script.c (0 downloads)
Last edited by JamesHH; 07/03/19 21:38.