algo (string name): int
Sets the algorithm identifier for identifying trades. Using algorithm identifiers is recommended in portfolio strategies that contain different trade algorithms; they are used to create separate strategy parameters, rules, and capital allocation factors per algorithm.
||The algorithm identifier (max. 15 characters, no spaces). If name ends with ":L", the algo is for long trades only; if it ends with ":S" the algo is for short trades only.
0 when the name string is NULL or empty, otherwise nonzero.
algo("TREND:L"); sets up the identifier
"TREND:L" for the current algorithm for long trades.
Short trades are suppressed.
- The assetList (if any) and an asset
must be selected before calling algo().
- For getting separate factors, parameters, or rules for long and short trades,
call the same algorithm with two algo identifiers that end with ":L"
and ":S", like the trade names in the message window and parameter files. Long trades
are then automatically suppressed on ":S" algos and
short trades on ":L" algos, but reverse positions
are still closed depending on Hedge. Don't
use ":L" or ":S"
for symmetric strategies with the same factors, parameters, or rules for long and short trades,
or for strategies that trade only long or only short.
- The algorithm identifier is stored in the
Algo string variable, and can be evaluated in strategies with the strstr function.
- Every algo call switches the trade statistics parameters and the OptimalF factors to the current statistics and factors of the selected algorithm identifier.
- Any algo/asset combination is a component in a portfolio strategy. The performance report lists strategy results separated by components. The Component variable is the number of the current component, starting with 0, and can be used as an array index.
- Algorithm specific data can be stored in the AlgoVar variables.
- For training algo dependent parameters separately, switch algos in a loop.
algo("TREND:L"); // algorithm identifier for a trend trading algorithm with long trades
enterShort(ifelse(strstr(Algo,":L"),0,Lots)); // suppress short trades when Algo ends with ":L"
enterLong, enterShort, loop,
string, asset, Algo, AlgoVar, TradeAlgo