Artificial Neural Network Advanced
The Expert Advisor receives signals from an artificial neural network. Trades are closed by an opposite signal. A signal is checked aft the close of a bar, therefore the EA can be tested and optimized using Open prices of the traded period specified in the Timeframe parameter. This feature greatly increases the speed of testing and optimization.
The EA can be used as an indicator through disabling the trading option. It will show signals on the chart as arrows, see the figure. The EA algorithm also includes the following functions:
- stop loss order trailing after reaching a certain profit;
- changing a position volume depending on the balance change;
- moving losing positions to breakeven.
- closing unidirectional trades by breakeven;
- limiting losses or profits of open trades;
- showing signal values on the chart.
- Take profit - take profit value;
- Stop loss - stop loss value;
- Start trailing if profit > (pips) - trail a stop loss order if the profit exceeds the specified value; 0 - trailing disabled;
- Start with lot - initial position volume increased in proportion to the balance change;
- Lotsize by balance - increasing lot in proportion to the balance increase, yes/no;
- Timeframe - the chart period, a signal is checked after the close of the bar of the specified period;
- Trade direction - choose trading direction;
- Do not trade if spread > - the EA will not trade if spread is higher than the specified value;
- Close deal by - deal closing method: at an opposite signal; RSI cross of the level of 50%, 60-40% (60 buy, 40 sell), 70-30% (70 buy, 30 sell);
- a1 ... a10 - inputs for the neural network used for the network training, values from 0 to 100 with any step;
- Reset in days - open a trade in the same direction if the specified number of trades has passed since the last trade opening;
- Amount of signals - open a trade if there is a specified number of signal confirmations on previous bars;
- ...in bars - the number of previous bars;
- Close losses - close losing trades (yes/no). If "no", a take profit of the previous losing trade is moved to a trade open level (breakeven) when an opposite signal appears. If the previous trade is profitable, it is closed;
- ...maximum deals with losses - maximum allowable value of open losing trades. Trades are opened till the limit is reached;
- Close deals if total loss profit > (%) - close all open trades if their loss or profit exceeds the specified value. Specify a negative value for loss and positive for profit
- ...close - choose trades to be closed upon specified profit or loss. Values: all; only loss; only profitable;
- Close couple deals by breakeven - close unidirectional trades by breakeven (yes/no);
- Slippage (in pips) - allowed slippage when opening a trade;
- Magic number - magic number of trades.
Training and testing example
The neural network has been trained (selection of parameters а1 ... а10) on EURUSD from 1 September to 1 November, 2016, every tick, М30, open prices, allowing closure of losing trades. Testing results on the period from September 1 to December 19 2016 are shown on the screenshots.
2. Added manual setting of the RSI indicator levels for closing deals.
2. Added selection of trades to closed upon reaching the specified profit or loss. Parameter ...close, values: all; only loss; only profitable.