Artificial intelligence explained for newbies

artificial intelligence

Artificial intelligence is a mysterious technique regarded as the holy grail by  newbies. I have a university degree in computer programming and artificial intelligence was one of my hobbies. Now, after I coded so many applications I know for sure when they work and when it don’t. And applied to forex trading, a neural network doesn’t work as expected, unfortunately. I won’t get into many technical details, in fact I shouldn’t have written this article in the first place but nowadays I see many sales pages claiming they discovered the holy grail. Such unscrupulous sellers are using the word AI just because it sounds good, it brings something new and naive newbies are jumping without a second thought.  Of course, that kind of system fail miserably after a few months, the most. In the following article, I will explain why, in layman’s terms.

Take the following code for example, written in pseudocode:
a=1;
b=2;
c=a+b
display(c);

It adds two numbers, a and b and displays the result. The computer already know how to add two or more numbers because the addition rule is already stored in the programming language specific libraries as a function. This is the classic approach.

Now back to AI. Consider the following data set:

2 2 4
1 2 3
4 5 9
3 2 5

The third number is the result of adding the first two numbers. By analyzing the data set, the computer must figure out what is the relation between the first two numbers and the third number in such a way that if two numbers that are not present in the data set are supplied it must be able to display the third number. In other words, the computer must learn the addition rule! This is artificial intelligence.

Before diving into details please note that we have a very exact pattern here: the third number is the sum of the first two numbers. We’ll need this information later.

What is a neural network and how does it work?
Basically, a neural network is a black box: it takes some inputs, process them, then returns the output. The block cell of a neural network is the neuron. Like a biological neuron, it takes inputs, process them, then returns the output. A biological neuron can have 2 states: excited and not excited (on and off) and its state is determined by the strength of its inputs (electrical signals).

neuron

neuron

x1..x7 are the inputs, w1..w7 are electrical signals associated with each input, f is the activation function and y is the result. w1..w7 are called weights. The mathematical model of a neuron is:

Y = f(Sum(xi*wi))

I won’t talk about the bias, threshold, layers, activation functions or network topology, I’ll stick to a basic explanation. The memory of a neural network lays in its weights. Let’s go back to our data set:

2 2 4
1 2 3
4 5 9
3 2 5

We have two inputs and one output. I assign a neuron for each input and one neuron for the output. The number of weights shouldn’t exceed the  number of inputs otherwise the network becomes over trained and any slightest deviation from the patters affects the output. If the number of weights is smaller than the number of inputs, the network won’t be able to learn the rule properly.

Our small network consists of two input neurons, a layer of two weights and one output neuron. A neural network can have more layers composed of weights: the output of one neural network is fed to another sub-neural network before displaying the final result (this is another interpretation of multiple layers model).

Neural network models

Neural network models

Model 1: one input neuron, one layer and one output

Model 2: two input neurons, one layer composed of two weights and one output

Model 3: three input neurons, two layers composed of three and respectively two weights and an output.

Our simple network is described by model 2.

The activation function (usually the sigmoid function) returns the strength of the signal. The sigmoid function is chosen because it is a symmetric function with values from -1 to 1.

By following the model 2 and mathematical description of a neural network, we must find the weights that satisfies the equations:

B1=sigma(A1 * W11 + A2 * W21)
B2=sigma(A1 * W12 + A2 * W22)
C1=sigma(B1*W3 + B2*W4)

where A1 and A2 are the first two numbers and C is the result. I won’t get into details of how to solve these systems because is beyond the knowledge of average current readers, but all you need to know is, after W11, W21, W12, W22, W3 and W4 are found, they represent the memory of our neural network. If instead of A1 and A2 we supply 10 an 21 as inputs, the neural network must return 31 as a result. The neural network has just learned the addition rule!

 

Do they work if applied to forex trading?

1. After all, a neural network is the ultimate form of curve fitting. It trades very well if the pattern on which the neural network is trained doesn’t change a bit, but it changes.

2. Neural networks are very good at finding patterns where the human eye can’t but there is simply too much noise on forex market.

3. It needs constant tweaking so it can be able to chase the market, and the tweaking is a laborious process that can take days and a large computing power.

4. The spikes caused by high impact news can kill any neural network because there isn’t any pattern to follow.

5. Trading near support and resistance lines or after high impact news are the only moments when we have a more than 50% chance of success but a neural network can’t spot these points by itself because there is no pattern (a NN can’t interpret the news or where the real resistance and support lines are, it’s much more than simply find the highs and lows).

6. History tends to repeat itself but it repeats a bit different.

Don’t waste your time with them, they are great but not for trading! If you see a sales page advertising them as the forex holy grail, just press the X button located at the right top of the page. Do that and save your money. 🙂

Not yet! 🙂 That would mean to close my main page also, because my new approach to forex trading consists in using neural networks and bayesian filters. 🙂

The catch is that I’m using them properly, solely for classification purposes. They are not trying to identify the pattern by themselves, they are used to filter the patterns I’m feeding them with! The way I’m using them, they are not trying to extract order out of chaos, but to filter the data I fed them with, the data that are considered to be valid.

I gathered inputs for as many forex robots I could find and selected only the winning trades. Then, I analyzed the market conditions prior to trade opening (volume, volatility, support and resistance points, how close the trade was from a few moving averages, and so on). I have created a pattern of winning conditions, I normalized it and fed the neural networks and bayesian filters with it. The results are great.