# Neural Networks

A Machine Learning concept (Learned models) in the LuxAlgo Library.

## What are Neural Networks?

A neural network is a function approximator built from layers of simple units. Each unit computes a weighted sum of its inputs, adds a bias, and passes the result through a nonlinear activation function; stacking such units in layers lets the network represent nonlinear relationships that a single linear model cannot. The weights are learned by minimizing prediction error on historical examples, almost always by gradient descent with backpropagation supplying the gradients. In trading tools the usual form is a small multilayer perceptron (MLP): an input layer of hand-built features, one or two hidden layers, and an output read as a forecast value or, through a [sigmoid or softmax](https://www.luxalgo.com/library/concept/sigmoid-softmax-transforms/), as class probabilities.

Flexibility is both the appeal and the hazard. A network with enough parameters can fit training data almost perfectly by memorizing noise, so in-sample accuracy means little; what counts is performance on data the model never saw, which makes an [in-sample / out-of-sample split](https://www.luxalgo.com/library/concept/in-sample-out-of-sample-split/) or walk-forward test non-negotiable. Chart-based implementations add constraints of their own: small datasets, features limited to what the platform computes, and retraining schemes that can quietly leak future information. A neural network is a fitting method, not a strategy; its value is set by the [features](https://www.luxalgo.com/library/concept/feature-engineering/) it is fed, the [label it is trained to predict](https://www.luxalgo.com/library/concept/label-definition-and-prediction-horizon/), and the honesty of its validation.

Architecture families matter less on charts than in research. Recurrent networks and their LSTM variant consume sequences natively, convolutional networks scan for local patterns, and transformer-style models power large-scale work, but nearly all of that lives off-platform, where real training infrastructure exists. On-chart neural scripts stay tiny by necessity: a perceptron or a one-to-two hidden-layer MLP, weights either pre-trained offline and pasted in as constants, or nudged bar by bar in an [online learning](https://www.luxalgo.com/library/concept/online-incremental-learning/) loop. Some indicators wearing the neural label are really fixed-weight formulas that never learn at all, which is worth checking before trusting the branding.

The training realities are unglamorous and decisive. Inputs need consistent scaling computed causally; class imbalance skews naive accuracy; and non-stationarity means a fit decays, motivating scheduled retraining under walk-forward rules. Raw outputs are scores, not probabilities, until checked by [calibration](https://www.luxalgo.com/library/concept/logistic-signal-calibration/), and averaging several independently initialized networks, an application of [ensemble voting](https://www.luxalgo.com/library/concept/ensemble-voting-of-signals/), is the cheap way to tame run-to-run variance. The Library spans the spectrum honestly: Noldo's ANN MACD ships offline-trained weights for BTC, while capissimo's perceptron strategy learns on the chart itself.

## How to identify what a neural indicator actually does

Neural branding covers everything from real learned models to dressed-up moving averages. A short audit separates them.

1. List the inputs and their normalization: what features feed the network, and is the scaling computed from past data only or from the whole visible chart.
2. Count parameters against training examples: a few hundred weights learned from a few hundred effective examples is memorization wearing a lab coat.
3. Find where training happens: offline with weights embedded as constants, online with per-bar updates, or nowhere, because the weights are hand-set and nothing is learned.
4. Check the retraining and normalization for lookahead: full-history rescaling or per-bar refits that touch future data rewrite the past and inflate the backtest.
5. Ask how it was validated: walk-forward or out-of-sample metrics are evidence; a beautiful full-history equity curve on the training data is not.

## How traders use it

- As a direction classifier: oscillator readings, returns, and volatility measures feed a small MLP whose output is read as the probability that price closes higher or lower over some horizon, then plotted as a signal line or entry arrows.
- As a learned composite: the network compresses several familiar inputs into one adaptive confluence score, which is then treated like any oscillator, with zones, crossovers, and divergence reads.
- As a filter on a base system: a rule-based setup only fires when the network's reading agrees, on the theory that the model captures conditions the fixed rules miss.
- With repaint discipline: models retrained every bar or normalized over the full visible history can rewrite past outputs, so [repaint-safe engineering](https://www.luxalgo.com/library/concept/repaint-safe-engineering/) (frozen weights, causal normalization) is what keeps the historical track honest.
- As a sizing input rather than a trigger: a calibrated probability output scales position size or skips marginal setups, which uses the model's graded confidence instead of flattening it into arrows.

## Neural Networks vs other learned models

- **Support Vector Machines** (https://www.luxalgo.com/library/concept/support-vector-machines/): SVMs separate classes with a maximum-margin boundary and a fixed kernel-defined feature map, trained by convex optimization; networks learn their own representation but train non-convexly, so different runs can land on different solutions.
- **Random Forest** (https://www.luxalgo.com/library/concept/random-forest/): A random forest averages many decision trees, is robust to feature scaling, and rarely collapses from one bad hyperparameter; a network is a single continuous fitted function, more sensitive to tuning and easier to overfit on small trading datasets.
- **kNN Analog Forecasting** (https://www.luxalgo.com/library/concept/knn-analog-forecasting/): kNN stores the history and compares the present against it at query time, with no training step; a network compresses history into fitted weights and discards the examples themselves.

## FAQ

### Can a neural network predict the market?

It can approximate whatever stable relationship exists between its inputs and target in the training data. Whether that relationship persists is the real question: markets are noisy and non-stationary, and much of what a flexible model fits is noise. Out-of-sample results, not training accuracy, are the only evidence worth weighing, and even those can decay as regimes change.

### What is an MLP in a trading indicator?

A multilayer perceptron, the simplest feedforward network: an input layer holding feature values, one or more hidden layers of weighted sums passed through nonlinear activations, and an output layer producing the forecast or class score. Most chart-based neural indicators are small MLPs over familiar inputs such as RSI, momentum, or normalized price changes.

### Why do neural network trading models overfit?

Because parameters are plentiful and independent examples are scarce. Overlapping windows, autocorrelated returns, and regime drift mean a few thousand bars carry less information than they appear to, while even a small network can hold hundreds of weights. The standard mitigations apply: fewer parameters, regularization, early stopping, and walk-forward validation that never lets the model touch its test data.

### Why are on-chart neural indicators so small?

Platform constraints. Charting environments offer no training frameworks, no GPUs, and a tight per-bar compute budget, so scripts are limited to perceptrons or tiny MLPs, often with weights trained elsewhere and pasted in as constants. That is not automatically bad, small models resist overfitting, but it means the heavy lifting, feature design and honest validation, happened off-screen or not at all.

### Do deep networks beat simple models on price data?

Published results are mixed and sensitive to the test design. On a single price series the signal-to-noise ratio is brutal, and regularized simple models with good features frequently match or beat deep architectures out of sample. Deep learning earns its complexity on richer inputs, order-book states, large cross-sections, alternative data, where there is structure worth the capacity. For chart-scale work, small and validated beats deep and hopeful.

### How much data does a neural trading model need?

More than the row count suggests. Overlapping labels and autocorrelation shrink the effective sample dramatically, so a rule of thumb is to keep learnable parameters well below the number of genuinely independent examples, then verify with walk-forward testing across different regimes. If the training window spans only one regime, the model has learned that regime, and its first out-of-regime trade is an experiment you paid for.

## Related concepts

- Kernel Regression: https://www.luxalgo.com/library/concept/kernel-regression/
- Gaussian Process Regression: https://www.luxalgo.com/library/concept/gaussian-process-regression/
- Kernel Density Estimation: https://www.luxalgo.com/library/concept/kernel-density-estimation/
- Support Vector Machines: https://www.luxalgo.com/library/concept/support-vector-machines/
- Decision Trees: https://www.luxalgo.com/library/concept/decision-trees/
- Gradient Boosting: https://www.luxalgo.com/library/concept/gradient-boosting/
- Random Forest: https://www.luxalgo.com/library/concept/random-forest/
- LSTM / Recurrent Networks: https://www.luxalgo.com/library/concept/lstm-recurrent-networks/
- Bayesian Classifiers: https://www.luxalgo.com/library/concept/bayesian-classifiers/
- Self-organizing Maps: https://www.luxalgo.com/library/concept/self-organizing-maps/

---

Source: https://www.luxalgo.com/library/concept/neural-networks/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/