
Artificial intelligence has moved from research labs into everyday trading tools. Many indicators and Expert Advisors (EAs) now advertise “neural network” or “AI” technology, and traders increasingly build their own models in Python. At the centre of most of these tools is the Deep Neural Network (DNN).
This guide explains what a DNN is in plain language, how it can be applied to Forex, how it differs from simpler methods such as KNN, and what you should check before trusting any neural network strategy.
What is a Deep Neural Network?
A Deep Neural Network (DNN) is a machine learning model made of many layers of simple processing units called neurons. Each neuron receives numbers, multiplies them by learned weights, adds them up and passes the result through an activation function. By stacking many layers, the network can learn complex, non-linear relationships between inputs and outputs.
A typical DNN has three types of layers:
- Input layer: receives the data, such as recent returns, indicator values or volume.
- Hidden layers: two or more layers that transform the data step by step. “Deep” refers to having several hidden layers.
- Output layer: produces the prediction, such as the probability that price will rise over the next few bars.
How a DNN Learns
A DNN learns from historical examples through a process called training:
- The network makes a prediction for a past example.
- A loss function measures how wrong the prediction was.
- An algorithm called backpropagation works out how each weight contributed to the error.
- An optimiser, such as Adam or stochastic gradient descent, adjusts the weights slightly to reduce the error.
- The process repeats over thousands or millions of examples.
After training, the network can make predictions on new data it has never seen. The key question is whether what it learned applies to the future or only to the past.
Types of Neural Networks Used in Trading
| Network type | How it works | Typical trading use |
| Feedforward DNN (MLP) | Data flows from input to output through dense layers | Classifying direction from a set of features |
| LSTM / GRU | Recurrent networks with memory of earlier inputs | Learning patterns in price sequences |
| CNN | Detects local patterns using filters | Reading chart-like inputs or multi-timeframe grids |
| Transformer | Uses attention to weigh different time steps | Longer sequences and multiple data sources |
For most retail traders, a simple feedforward DNN or a small LSTM is enough to start with. Larger models need far more data and are easier to overfit.
Building a DNN Model for Forex

Define the target
Decide exactly what the model should predict. Common choices are the direction of price after N bars (classification) or the size of the next move (regression). A clear, realistic target matters more than a complex model.
Choose features
Features describe the market at each bar. Examples include:
- Returns over several look-back periods, calculated from OHLC data.
- Volatility measures, such as ATR.
- Momentum indicators, such as RSI.
- Volume information, such as tick volume relative to its average.
- Distance from key levels, such as the Point of Control or VWAP.
- Time features, such as the trading session or Kill Zone.
Prepare the data
Scale features to similar ranges, remove errors and make sure every feature uses only information available at that moment. Using future data by mistake, known as look-ahead bias, is one of the most common reasons models look excellent in testing and fail live.
Split the data correctly
Financial data is a time series, so never shuffle it randomly. Use separate periods for training, validation and testing, in time order. Walk-forward testing, where the model is re-trained on a rolling window and tested on the following period, gives a more realistic picture.
Train and regularise
Use techniques such as dropout, early stopping and weight regularisation to stop the network from memorising noise. Keep the model as small as possible while still performing well.
Evaluate as a trading strategy
Accuracy alone is misleading. Convert predictions into trades and measure profit factor, maximum drawdown and risk-adjusted returns, including spreads, commissions and swaps.
Using DNN Models in MetaTrader 5
Traders usually build and train models in Python with libraries such as TensorFlow, Keras or PyTorch. MetaTrader 5 supports running models exported in the ONNX format directly from MQL5, which allows a trained network to be used inside an indicator or EA. Python can also be connected to MT5 through the official MetaTrader 5 Python package for data access and trade execution.
DNN vs KNN and Other Methods
| Feature | KNN | DNN |
| Complexity | Simple, few settings | Complex, many settings |
| Data needed | Moderate | Large |
| Interpretability | Easy to explain | Hard to explain (“black box”) |
| Training | No training, compares with history | Requires training |
| Overfitting risk | Moderate | High without care |
A more complex model is not automatically better. In noisy markets like Forex, simple models often perform as well as deep ones. Many traders start with KNN or linear models as a benchmark before moving to neural networks.
The Main Risks of Neural Network Trading
- Overfitting. A DNN can memorise historical noise and produce beautiful backtests that fail in live trading.
- Non-stationary markets. Relationships change as interest rates, volatility and market participants change. A model trained on one regime may fail in another.
- Low signal-to-noise ratio. Short-term Forex price changes are largely random, so even a good model may only have a small edge.
- Black-box behaviour. It is hard to know why a network makes a decision, which makes it difficult to trust during unusual conditions.
- Data differences. Tick volume and prices differ between brokers, so a model trained on one feed may behave differently on another.
How to Evaluate an AI or Neural Network EA
Many products use “AI” or “neural network” in their marketing. Before buying or running one, check:
- Out-of-sample results: has the EA been tested on data it was not trained on?
- Live or forward-tested performance: a verified live track record carries more weight than a backtest.
- Drawdown and risk settings: how large were the worst losses, and can you control risk per trade?
- Broker and spread sensitivity: does performance survive realistic spreads and slippage?
- Transparency: does the developer explain the inputs, timeframe and market conditions the model was designed for?
Always run an AI EA on a demo account first and start with small position sizes.
Combining DNN Signals With Market Context
Neural network outputs work best as one input in a broader process. For example, you can take DNN long signals only when price is near the Value Area Low, inside a bullish Potential Reversal Zone, or after a Market Structure Shift. This combines statistical learning with levels that make sense on the chart.
Frequently Asked Questions
What is a DNN in trading?
A Deep Neural Network is a machine learning model with several hidden layers that learns patterns from historical market data to predict direction or price movement.
Can neural networks predict Forex prices?
They can find patterns that offer a small statistical edge, but they cannot reliably predict prices, and many models fail outside their training data.
What is the difference between DNN and LSTM?
LSTM is a type of neural network designed for sequences. A basic DNN processes a fixed set of features, while an LSTM remembers information from earlier steps in a sequence.
Can I use a neural network in MT5?
Yes. Models can be trained in Python and exported to ONNX format to run inside MQL5 indicators and EAs.
Conclusion
Deep Neural Networks bring powerful pattern recognition to Forex trading, but they also bring new risks, especially overfitting and changing market conditions. Start with a clear target, clean data and strict walk-forward testing, compare results with simpler models, and combine signals with market structure and Volume Profile. Used carefully, a DNN can be a valuable tool; used blindly, it is just a more complicated way to lose money.
Risk warning: Trading Forex and CFDs on margin carries a high level of risk and may not be suitable for all investors. Machine learning and AI models do not guarantee profits, and past performance does not predict future results. This article is for educational purposes only and is not investment advice.
