Actually it is Hedge = 5 specifically which is broken when combined with a loop(). Here's a demonstration.
function run() {
NumYears = 1;
Hedge = 5;
while(asset(loop("EUR/USD", "GBP/USD"))) {
if (Bar % 99 == 0) {
enterLong();
}
}
}
... [Test] Produces:
Portfolio analysis OptF ProF Win/Loss Wgt%
EUR/USD avg .000 ---- 0/0 -0.0
GBP/USD avg .000 0.78 2614/3232 100.0
GBP/USD .000 0.78 2614/3232 100.0
GBP/USD:L .000 0.78 2614/3232 100.0
GBP/USD:S .000 ---- 0/0 -0.0
If you swap the order of the assets in the loop, you get this Portfolio analysis instead.
Portfolio analysis OptF ProF Win/Loss Wgt%
EUR/USD avg .000 0.74 2687/3160 100.0
GBP/USD avg .000 ---- 0/0 -0.0
EUR/USD .000 0.74 2687/3160 100.0
EUR/USD:L .000 0.74 2687/3160 100.0
EUR/USD:S .000 ---- 0/0 -0.0
Expected: same performance regardless of order of elements in asset loop.
Expected: >0 trades for all assets. The enterLong is unconditional every 99th bar, so there should be thousands of trades, same for all assets.