An independent plugin for AmiBroker · built for serious traders Documentation & support →

Neural Networks

Build, train and run neural networks directly from AFL — feed-forward MLP, LSTM, GRU, TCN and Transformer — with ensembling and the anti-overfitting controls that matter on market data.

Neural Networks

The Toolbox lets you build, train and run neural networks directly from AmiBroker formula language, so you can add a flexible, non-linear way of combining indicators to the platform you already use. Where a moving-average crossover uses a fixed rule you chose yourself, a network discovers the rule from your history — including subtle interactions that would be hopeless to write by hand.

Five architectures

The default is a feed-forward network (an MLP), which treats each bar independently and is fast, robust and the right choice for almost everything. Four sequence models read a window of consecutive bars instead: the recurrent LSTM and GRU step through the window in order and carry an internal memory; the TCN slides a fast causal convolution across the whole window at once; and the Transformer uses self-attention to weigh which past bars matter most. The recurrent models stack into genuinely multi-layer networks. You choose the model, the hidden layers and the activation for each layer with a single set of function calls.

Steadier predictions, and more ways in

Rather than rely on one network, you can ensemble several — train a handful at once and average their predictions for a steadier, more reliable result. It works with any model type, and the saved ensemble runs automatically. Two further options help the network learn: layer normalisation stabilises training in deeper feed-forward networks, and categorical embeddings let you feed a discrete input — a market regime, the day of the week, any integer category — so the network learns a compact representation for each value instead of treating the ID as a number on a line.

Fourteen training algorithms

You are not limited to plain back-propagation. The Toolbox ships fourteen optimizers, from the resilient-propagation family (RPROP, iRPROP+, SARPROP) to the modern Adam family (Adam, AdamW, NAdam, AMSGrad, RMSProp and more). iRPROP+ is a robust set-and-forget default that needs no learning rate; AdamW pairs adaptiveness with built-in weight decay when overfitting is a concern. Learning-rate schedules — step, cosine annealing and SGDR with warm restarts — and minibatch training are available too.

Built to fight overfitting

The real challenge on noisy market data is not fitting the training bars but predicting new ones, and that comes down to controlling overfitting. The Toolbox holds back a slice of your data as an unseen test set, reports the training and test error so you can actually see overfitting happen, and gives you early stopping, dropout, weight decay, gradient clipping and proper weight initialisation to beat it. Automatic input and output scaling keeps every series on a comparable footing — feed a rate of change rather than raw price and predictions become far more reliable.

Two ways to work

Standard networks train once on a block of history and save to a file you run later — and a single network can be trained across a whole pool of symbols for a more general model. The adaptive walk-forward family does training and prediction in one call, retraining on a rolling window as it walks the chart so every prediction is genuinely out-of-sample. A trained standard network can even be compiled to pure AFL — its weights written out as ordinary formula language, so nothing is hidden in your backtest. Everything is driven from simple AFL function calls and comes with full documentation; the companion Neural Network Wizard builds and trains the networks for you visually.