Originally Posted by jcl
I don't know, but run it in test mode and check the log - there you can proably see why it does not train. Also, better remove the malloc. Functions like malloc are resource heavy. You normally use them only at initialization, not at any bar.


Thanks for the tip on malloc.

It turns out the problem was the way I was using the loop function. I was looping once to calculate the indicator, and then trying to loop again. However, following the manual which suggests using either for(listed_assets), for(used_assets) or a for-loop, I get some unexpected results:

1. for(listed_assets) produces the SIGNALS files correctly (one for each symbol), but it give me the error: "Error 015: invalid advise signal[0] at bar 251"
2. for(used_assets) gives the same SIGNALS files and no error.
3. the for-loop results in each signal repeated twice in the SIGNALS files.

Any insights on why I am seeing this, or what the correct approach is here? Here is the test code for this issue:

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

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;

// This initialize the assets
while(asset(loop(Assets))) {
}

char* symbol;
int i;
// #1:
//for(listed_assets) {
// #2:
for(used_assets) {
// #3:
//for (i = 0; symbol = Assets[i]; i++) {
adviseLong(SIGNALS, 0, simple_returns(1, 1), simple_returns(2, 1), simple_returns(3, 1));
enterLong();
}
}