loop(void* p1, void* p2, ... ) : void*

loop(Assets) : void*

Function enumerating assets and/or algos, normally used for training parameters or rules separately per portfolio component. It gets a list of pointers that can be asset or algo names or algo function pointers. In [Test] and [Trade] mode it returns the first pointer on the first call, the next pointer on the next call and so on. After the last pointer, 0 is returned. In [Train] mode it returns the first pointer in the first training cycle, the next pointer in the next training cycle and so on. Training cycles end after the last pointer.


p1 on the first call or training cycle, p2 on the next call or training cycle, and so on. The last call returns 0.


p1, p2 ...

Up to 40 pointers or strings; normally a string with an asset or algo name, or a trade function pointer.


Predefined array with all asset names; used for looping through all assets in the asset list.


Example (see also Workshop 6):

// portfolio strategy with 3 assets and 3 trade functions
function tradeTrendLong()
function tradeTrendShort()

function tradeBollinger()
function tradeFunc(); // empty function pointer
function run()
    "GBP/USD")) // loop through 3 assets
  while(tradeFunc = loop(
    tradeBollinger)) // and 3 different trade algorithms
     asset(Loop1); // select asset
     tradeFunc();  // call the trade function

See also:

optimize, while, algo, asset, Assets

► latest version online