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

loop(Assets) : void*

This function takes a list of pointers, strings, or asset names as parameters, and returns the first pointer on the first call, the next pointer on the next call and so on. After the last pointer, loop returns 0. The loop function is normally used to select assets and trade algorithms for a portfolio strategy, and to treat every asset/algo combination separately in [Train] mode.


p1 on the first call or training run, p2 on the next call or training run, 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. The first asset of the list determines the bar generation.


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