In workshop 6, the use of the loop function is demonstrated through portfolio strategy:

while(asset(loop("EUR/USD","USD/JPY")))
while(algo(loop("TRND","CNTR")))
{
if(Algo == "TRND")
tradeTrend();
else if(Algo == "CNTR")
tradeCounterTrend();
}

on my screen ,in the tutorial, it appears that the second loop is not indented but since it won't work without indentation since the loops won't be nested I assume it is just a problem on my screen for some reason...

My real question comes after reading the loop function help file that states that the pointers/strings are returned in sequence on each successive call to the loop function and 0 when there are no arguments to loop upon. So, after the inner loop has done for "EUR/USD" and I move to "USD/JPY", why the inner loop function don't return 0? Why has it undergone a "reset" and returning the pointers in sequence again?
I understand it works but I don't understand why - since this function clearly retains its state between function calls I don't understand what makes it "rewind"?

Hopefully, someone can shed some light on this point.

Last edited by eyal; 05/04/16 16:36.