Neural network 2 Moving Averages
- Experts
- Vladimir Mikhailov
- Versão: 1.5
- Atualizado: 2 abril 2020
A neural network Expert Advisor based on two moving averages with the training mode. Train the Expert Advisor on selected examples and make a profit in real life. The EA can work on any instrument and in any timeframe.
Trading Algorithm of the EA
Two moving averages are analyzed by the neural network core, which produces commands to buy or sell.
the values of two moving averages, fast (FMA) and slow (SMA), are provided to the first layer, at the second layer it calculates two neurons responsible for Buy (N buy) and Sell (N sell), the decision to buy or sell is made at the third level.
Block diagram of the neural network is shown in the figure.
Expert Advisor Training
In the training mode the EA "remembers" the values of moving averages marked by the user on the chart of the currency instrument. In the future, during normal operation, it recognizes the values of the moving averages.
To train the EA mark at least one long and one short trade on the chart. To indicate a long trade use the "Buy" arrow, and for the short trade use the "Sell" arrow. You can place more arrows on the chart. The more arrows, the longer will be the process of training. Presence of any other objects on the chart other than the arrows is not desirable.
After the training, folder "NN 2MA" will be created in the common folder of the terminal. It will contain file "HHHHHH_NN_2MA.bin" with the settings of the trained neural network. XXXXXX in the file name is the name of the financial instrument. In normal operation, the EA loads the data from the file. If the file is not found, it will use the default settings. By default, the EA is trained at USDJPY and one-hour timeframe, the trades are selected in 2012.
The following input parameters are responsible for the EA training:
- The number of weights per neuron. Equal to the length of the MA. Default - 48.
- The number of training cycles - default 100. The higher the value, the longer the training process will be. In the trial version it is 10.
- Factor b - the value affects the speed of the correction of weights of neurons, is used for training the network. The default value is 0.7, does not need changing.
- Learning mode EA - enables the training mode of the EA.
Examples of specifying trades for training the EA are available in the figure.
The Normal Mode Settings
Settings of Moving Averages
You can adjust the settings of each moving average: the period, the price, the calculation mode.
Trade Settings
- Volume of order - default is 0,1.
- Value of slippages in points - default is 30.
- Number of attempts to open a position - default is 5.
- Level StopLoss in points - default is 0.
- Level TakeProfit in points - default is 0.
- Level TrailingStop in points - default is 650.
- Allow money management - control the order size to enter the market, enabled by defalt. If the mode is disabled, the order size is taken from the "Volume of order" parameter.
- The volume of orders as a percentage of the deposit - used to control the order size, default is 5 percent.
- Adding to the open position - enabled by default. If there is a signal to enter the market in the direction of an open position, the EA enters the market.
Settings of Neural Network
- The number of weights per neuron. Equal to the length of the MA. The higher the value, the more accurate will the current market state be recognized, but it reduces the number of trades. The lower the value, the less accurate will the current market state be recognized, but the number of trades increases.
- The value of neuron activation. The value is approximately 0.75 of the value of "The number of weights per neuron". The higher the value, the stricter is the selection of neurons for making a decision. In the trial version it is 40.
- The number of training cycles - default is 100.
- Factor b – the weight correction speed, default is 0.7.
- Learning mode EA – the EA training mode.
During training, the maximum values of the neurons will be shown in the comments on the chart. These values can be used as an activation value of the neuron.
An example is shown in the figure.
Other Settings
- Enable comments - enables comments on the chart.
- Magic Number of Advisor.
- Pause after trading in milliseconds.
By default, the EA is trained on USDJPY H1 on two trades in 2012. The result of the Expert Advisor testing in 2013 is shown in the figure.
Спасибо! Очень иинтересный советник. Вопрос: он мультивалютный, на несколько пар или таймфреймов поставить можно и что для этого надо?
Ой как я погорячился!- сегодня показывает отличные результаты, а завтра- на тех же настройках либо слив, либо вообще ноль! Хорошо не успел поставить в работу.