Home › Documentation › Building strategies
Block 6

How the optimization works

1
Instance expansion

Every indicator with a period range is expanded into concrete instances. If there are several sources, one instance is created for each source × period combination.

2
Condition generation

Group A: indicator × threshold × operator. Group B: every pair of instances × operators. With MaxAnd ≥ 2, all the AND combinations on top of that.

3
Parallel backtest (CPU or GPU)

Each combo is backtested over the In-Sample period. By default the work is spread across every CPU core; if you tick GPU and an OpenCL device is available, the sweep runs on the graphics card (one GPU thread per combo), typically 10-15× faster. Entry at the next Open; exit by intrabar TP/SL or by signal at the close.

4
Filtering and ranking

Only strategies meeting the MinTrades floor get through. The results are ranked by the criterion you chose (Win%, PF, Net P. %…). Select any of them to see its full report.

🧮 Example — the combinatorial explosion

This is where you see why MaxAnd is so powerful… and so dangerous. Suppose the generation produces 500 single conditions (indicators × periods × operators × thresholds). The number of strategies to backtest, by MaxAnd:

MaxAnd = 1
500
500
MaxAnd = 2
125K
500 + C(500,2)
MaxAnd = 3
20.7 M
+ C(500,3)

From 500 to 20 million just by raising MaxAnd from 1 to 3 (and with more base conditions the jump goes into the billions). Two consequences: (1) this is why the Random mode exists — to sample at random when the space is astronomical; (2) with that many tests, some will win by pure chance — which is why MaxAnd=3 demands a high MinTrades, ranking by ProfitFactor and validation afterwards (PBO/DSR, Walk-Forward).

In-Sample vs Out-of-Sample

AniQuant splits the data. The In-Sample (IS) period is used to find the best conditions; the Out-of-Sample (OS) one checks whether the strategy generalizes to data the system never saw.

IN-SAMPLE
The engine trains here. A good strategy: PF > 1.5 in IS.
OUT-OF-SAMPLE
Unseen data. If it also works here, the logic is sound and not a fluke.
Try it yourself

AniQuant can be tried free for 30 days, with every module and no card.

← Previous
Exit conditions: stops, targets and trailing
Next →
Strategy generation: exhaustive, random, genetic
More in Building strategies