### Author:

gpwr

### Description:

Two Forex - using indicator

*Neuron* *network* is nothing more than a nonlinear model outputs as a function of inputs. At the entrances served user data, such as the sample time series. The meaning of the output is also set by the user, for example, signals 1 = buy / 0 = sell. The structure of the network, again set by the user. The network consists of a direct distribution

- *The input layer* (input layer), whose elements are inputs,

*Hidden layers* (hidden layers), consisting of computational nodes called *neuron*

*The output layer* (output layer), which consists of one or more

All nodes of neighboring layers are linked. These connections are called *synapses*. Each synapse has a *weight* (weight w [i, j, k]), which are multiplied by the data transmitted by synapses. Data moves from left to right is inputs from the network to its outputs. Hence the name "direct distribution network." The total sample of this network is depicted in the picture below

The data are processed

1. 1. All of the inputs multiplied by the appropriate weight, you are added

2. 2. Then, the resulting amount handled *activation function* *neuron* *and* (activation or firing function) and sent to the only exit.

The meaning of the activation function

f(x)=1/(1+exp(-x)) f (x) = 1 / (1 + exp (-x))

The threshold of activation of this function is 0. This threshold can be shifted on the horizontal axis at the expense of an additional entrance *input bias* (bias input), which is assigned a certain weight in the same way as other inputs

Thus, the number of inputs, layers, *back propagation of errors* (ALO) and the method of *genetic improvement.*

### Attached files:

BPNN.zip - archive all the files needed to create a DLL file

BPNN Predictor.mq4 - predictive indicator of future value prices

Buy-Sell Classificator.mq4 - predictive indicator buy / sell signals.

Train() и Test(). Library BPNN.cpp file contains two functions: Train () and Test (). Train () is designed to train the network to provide input and output data. Test () is for calculating output data based on the weights obtained after running Train ().

ВInput (green color) and output (blue) parameters of the function **Train ()** are:

double inpTrain [] - input (older first)

double outTarget [] - Imprint (oldest first)

double outTrain [] - exits the network after training

int ntr - the number of training sets of input-output

int UEW - Managing key external values to initialize the weights (1 = use extInitWt [], 0 = use random numbers)

extInitWt [] - original values of weights

double trainedWt [] - the values of weights after training

int numLayers - number of layers in the network including input, hidden and output

int lSz [] - array size numLayers, which kept the number of

int OAF - a key feature in the activation of output

double LR - speed training

double MF - the moment of learning rate

int nep - the maximum number of training steps (epochs). Epoch consists of checking all the training sets.

double maxMSE - mean error, in which the learning stops.

Input (green) and output (blue) parameters of the function **Test ()** are:

double inpTest [] - input data (older first)

double outTest [] - Imprint

int ntt - sets of input and output data

double extInitWt [] - original values of weights

numLayers - number of layers in the network including input, hidden and output

int lSz [] - array size numLayers, which kept the number of

Using the activation of output

### Examples of indicators used neuron Network:

**BPNN Predictor.mq4** - predicting future prices. Network input parameters are the relative increments in prices:

x [i] = Open [test_bar] / Open [test_bar + delay [i]] -1.0

where delay [i] taken from the Fibonacci series. Network output is predicted a relative increase of future prices. Activation function in output layer is deactivated.

Input parameters are an indicator

extern int lastBar - number of the last bar

extern int futBars - the number of future predicted bars

extern int numLayers - number of layers in the network including input, hidden and output

extern int numInputs - the number of network inputs

extern int numNeurons1 - the number of

extern int numNeurons2 - the number of

extern int numNeurons3

extern int numNeurons4

extern int numNeurons5

extern int ntr - the number of training sets of input-output

extern double LR - the speed of learning network

extern double MF - coefficient of the time learning network

extern int nep - the maximum number of training steps (epochs)

extern int maxMSEpwr - exponent used to calculate the maximum allowable mean-square error learning maxMSE = 10 ^ maxMSEpwr

**Buy-Sell Classificator.mq4** - индикатор предсказывающий buy/sell сигналы. **Buy-Sell Classificator.mq4** - predictive indicator buy / sell signals. As in the previous example, the input network served

x[i]=Open[test_bar]/Open[test_bar+delay[i]]-1.0 x [i] = Open [test_bar] / Open [test_bar + delay [i]] -1.0

for bars, which in the past received signal to buy or sell. These last signals are ideal as input signals to obtain a given profit. Network output signal is 1 or 0 = buy = sell. The output layer activation function.

extern int lastBar - number of the last bar

extern int minProfit - the minimum profit in order to find the ideal entry point in the past

extern double threshold - the threshold for recognizing the output signals as 0 or 1

extern int numLayers - number of layers in the network including input, hidden and output

extern int numInput - the number of network inputs

extern int numNeurons1 - the number of

extern int numNeurons2 - the number of

extern int numNeurons3 extern int numNeurons3

extern int numNeurons4 extern int numNeurons4

extern int numNeurons5

extern int ntr - the number of training sets of input-output (depends on the number of buy / sell signals in the past, 0 selects all valid signals)

extern double LR - the speed of learning network

extern double MF - coefficient of the time learning network

extern int nep - the maximum number of training steps (epochs)

extern int maxMSEpwr - exponent used to calculate the maximum allowable mean-square error learning maxMSE = 10 ^ maxMSEpwr

Arrow to the right of the vertical green lines indicate buy / sell signals generated by the network for testing "the future" bars. The arrows on the left shows the optimal entry point in the past.

### Installation of files:

Copy attached DLL file in the C: \ Program Files \ MetaTrader 4 \ experts \ libraries

Enables the use of DLL in metatrader: Tools - Options - Expert Advisors - Allow DLL imports

If the DLL file does not work, compile yourself. All necessary files are contained in BPNN.zip.

## 1 comment:

nice nn indicator you can find on NNEA project. www.NNEA.net

Post a Comment