TrainMode

Training method; affects the way how parameters and factors are generated in the training process. The following flags can be set :

Range:

ASCENT Ascent optimization (default). Evaluates the effect of any parameter on the strategy separately. Walks through all parameter ranges and seeks for 'plateaus' in the parameter space, while ignoring single peaks. This is normally the best algorithm for a robust strategy, except in special cases with many mutually dependent parameters.
BRUTE Brute force optimization (Zorro S required). Evaluates all parameter combinations and selects the most profitable combination that is not a single peak. Can take a long time when many parameters are optimized or when parameter ranges have many steps. Useful when parameters can affect each other in complex ways. Brute force optimization will likely overfit the strategy, so out-of-sample or walk-forward testing is mandatory.
GENETIC Genetic optimization (Zorro S required). A population of parameter combinations is evolved toward the best solution in an iterative process. In each iteration, the best combinations are stochastically selected, and their parameters are then pair-wise recombined and randomly mutated to form a new generation. This algorithm is useful when a large number of parameters per component must be optimized or when parameters affect each other in complex ways. It will likely overfit the strategy, so out-of-sample or walk-forward testing is mandatory.
TRADES Optimize using trade sizes (Lots). Large trades get more weight. Set this flag when the trade volume matters, f.i. for portfolio systems that calculate their capital distribution by script. Otherwise trade sizes are ignored in the training process.
PHANTOM Optimize ignoring phantom trades. Otherwise phantom trades are treated as normal trades in the training process.
PEAK Optimize toward the highest single peak in the parameter space, rather than toward hills or plateaus. This can generate unstable strategies and is for special purposes only. For instance when optimizing not a parameter range, but a set of different algorithms or different assets.
ALLCYCLES Generate individual OptimalF factor files for all WFO cycles, instead of a single file for the whole simulation. This produces low-quality factors due to less trades, but prevents backtest bias.
SETFACTORS Generate factor files not with the OptimalF algorithm, but by script with a user-defined algorithm. For this, set OptimalF, OptimalFLong, OptimalFShort to a script calculated value in the FACTORS training run (if(is(FACTORS)) ...).

NumParameters

Number of parameters to optimize in the current loop in training mode (read/only).

ParCycle

Current parameter or current generation, runs from 1 to NumParameters in Ascent mode, or from 1 to Generations in Genetic mode (read/only).

StepCycle

Number of the optimize cycle, starting with 1 (read/only).

StepNext

Set this to 0 for early aborting the optimization.

Population

Maximum population size for the genetic algorithm (default = 50). Any parameter combination is an individual of the population. The population size reduces automatically when the algorithm converges and only the fittest individuals and the mutants remain.

Generations

Maximum number of generations for the genetic algorithm (default = 50). Evolution terminates when this number is reached or when the overall fitness does not increase for 10 generations.

MutationRate

Average number of mutants in any generation, in percent (default = 5%). More mutants can find more parameter combinations, but let the algorithm converge slower.

CrossoverRate

Average number of parameter recombinations in any generation, in percent (default = 80%).

Type:

int

Remarks:

Example:

setf(TrainMode,TRADES+PEAK);

See also:

Training, optimize, advise, OptimalF, TrainCycle, setf, resf
► latest version online