Discussion of article "Experiments with neural networks (Part 3): Practical application"

 

New article Experiments with neural networks (Part 3): Practical application has been published:

In this article series, I use experimentation and non-standard approaches to develop a profitable trading system and check whether neural networks can be of any help for traders. MetaTrader 5 is approached as a self-sufficient tool for using neural networks in trading.

This EA modification uses stop loss and take profit to exit. Strategy 1 perceptron and 4 slope angles of  TEMA indicators. Perform optimization 10 times. Structures of slope angles and optimization principles can be found in the first article. There is no point in repeating them here.

Optimization result:

Optimization result


Optimization result

A large number of results of the complex criterion 99.99. Profit factor at the high level of 4-8.

Author: Roman Poshtar

 

Wow! Roman,

This article covers exactly what i am trying to accomplish!. 

Using either a 3 or 4 layer DNN, I ran the tests for a day and exported the results to Excel via the XML process on the Optimization Tab to create an Excel spreadsheet which I saved as a CSV file.  Using the CSV file, I am planning to import it into the EA and then run an optimization to select the best strategy out of the highest 1000 optimized results in a forward data test.  A couple of things I have learned.  First save the EA inputs to a .SET file in mql5\profiles\tester and you can edit the .SET file in NotePad,its much easier than using the input tab to modify groups of input.  The second thing is the tests I ran into a lot of very small number of trades. Less than 0-100 over 2 years, so I eliminated them.  The final one is be careful of commas in the CSV file, especially if you have values over $1000.00.  The equity and profit columns have a comma set for 1000 values so when the data is saved to a CSV file, additional commas are included.  If you are using StringSplit as I am to identify the start and then parse the optimized neurons into the Weight array, the two additional commas must be included in the calculations.

I am attaching a PNG file of the equity scatter graph for a completeed optimization run for a 2 year 433 DNN using EURUSD H4 on the Original function.  As you can see,there is a preponderance of results at or or above the 2900 line and that the number above increases dramatically as number of optimizations nears the end of the run which is expected.  My plan is to choose the best 1000, and then use the forward data to identify the the best corresponding optimized weights from the previous optimization.  Since genetic optimizations increase exponentially based on the number of layers as well as the number of neurons, A full GA optimization for a large number of neurons and complex trade strategies and stop loss calculations will be impossible for most machines.  However, identifying the base line e.g. 2900, and also getting a couple thousand results to use should substantially result in more reasonable GA run times and also should result in good but not the best options for the EA for forward testing on live data.  I I have found out that you can export the optimizations to Excel while the GA Agents continues to run, thus you can determine when you have a 100 optimizations above the base line using Excel's COUNTIF function.

 
CapeCoddah #:

Wow! Roman,

This article covers exactly what i am trying to accomplish!. 

Using either a 3 or 4 layer DNN, I ran the tests for a day and exported the results to Excel via the XML process on the Optimization Tab to create an Excel spreadsheet which I saved as a CSV file.  Using the CSV file, I am planning to import it into the EA and then run an optimization to select the best strategy out of the highest 1000 optimized results in a forward data test.  A couple of things I have learned.  First save the EA inputs to a .SET file in mql5\profiles\tester and you can edit the .SET file in NotePad,its much easier than using the input tab to modify groups of input.  The second thing is the tests I ran into a lot of very small number of trades. Less than 0-100 over 2 years, so I eliminated them.  The final one is be careful of commas in the CSV file, especially if you have values over $1000.00.  The equity and profit columns have a comma set for 1000 values so when the data is saved to a CSV file, additional commas are included.  If you are using StringSplit as I am to identify the start and then parse the optimized neurons into the Weight array, the two additional commas must be included in the calculations.

I am attaching a PNG file of the equity scatter graph for a completeed optimization run for a 2 year 433 DNN using EURUSD H4 on the Original function.  As you can see,there is a preponderance of results at or or above the 2900 line and that the number above increases dramatically as number of optimizations nears the end of the run which is expected.  My plan is to choose the best 1000, and then use the forward data to identify the the best corresponding optimized weights from the previous optimization.  Since genetic optimizations increase exponentially based on the number of layers as well as the number of neurons, A full GA optimization for a large number of neurons and complex trade strategies and stop loss calculations will be impossible for most machines.  However, identifying the base line e.g. 2900, and also getting a couple thousand results to use should substantially result in more reasonable GA run times and also should result in good but not the best options for the EA for forward testing on live data.  I I have found out that you can export the optimizations to Excel while the GA Agents continues to run, thus you can determine when you have a 100 optimizations above the base line using Excel's COUNTIF function.

Thank you for your interest in my publications. I think your ideas can be implemented. But as you can see, everything rests on the iron part of our question - computers.

 

This is incredible work, thank you Roman!

I am running into an issue where I am unable to compile any of the Perceptron MQ5s "1 perceptron 4 angle SL TP - trade" for example has 22 errors, most of them being semicolon expected. Am I missing something or did I do something wrong?



 
Alexander Day #:

This is incredible work, thank you Roman!

I am running into an issue where I am unable to compile any of the Perceptron MQ5s "1 perceptron 4 angle SL TP - trade" for example has 22 errors, most of them being semicolon expected. Am I missing something or did I do something wrong?



Thanks for the feedback. Set preferences in Excel. Change , to . The system symbol for the separation of numbers with a floating coma.

 
Roman Poshtar #:

Thanks for the feedback. Set preferences in Excel. Change , to . The system symbol for the separation of numbers with a floating coma.

Appreciate your reply! I get the errors even if I open the MQL that comes in the zip file and try to compile that without any modification. Some of them don't error but almost all of the perceptrons do. 
 
Alexander Day #:
Appreciate your reply! I get the errors even if I open the MQL that comes in the zip file and try to compile that without any modification. Some of them don't error but almost all of the perceptrons do. 

You have an error in a file (Symbolinfo.mqh) not in perceptrons.

 
I trained various instruments using the provided EAs( which are very interesting), I wanted to test the EAs one a live market chart but they don't open trades. What could the problem be?
 
Kekeletso Mofokeng #:
I trained various instruments using the provided EAs( which are very interesting), I wanted to test the EAs one a live market chart but they don't open trades. What could the problem be?

Thanks for the feedback. Which EA does not work? If it works in the strategy tester, then it should work in real life.

 

Roman,

One possible reason the EA doesn't work in the Strategy tester is that the "File Sandbox" location changes when optimizing into an Agernt.  I just ran into that issue and am trying to fix it.  I haven't looked at your latest code yet. My suggestion is to us WinFile.mql to escape the SandBox and use WinAPI calls to directly read and write files.  See the discussion on

how to read an csv-file into a string with the Windows-Functions?

which offers several upgrades to WinFile, notably changing some ints into longs.  If you are trying to read a CSV file and obtain every line, I suggest using the "ReadWholeFile' function and doing the parsing internally instead of relying on "ReadLineFromFile" which cause a system crash that I cannot identify. 

Another problem could be the revised Perceptrons are only selecting one trade at the beginning of the run and closing it when the optimizing run ends.  This looks great in the Tester but doesn't work for actual trading.  In looking at my Optimization report, I was surprised to find that there were several hundred passes that resulted in only one trade but had a very good profit for the optimization period e.g. the trade was put on at the start and closed when the optimization run ended.

 
CapeCoddah #:

Roman,

One possible reason the EA doesn't work in the Strategy tester is that the "File Sandbox" location changes when optimizing into an Agernt.  I just ran into that issue and am trying to fix it.  My suggestion is to us WinFile.mql and see the discussion on

how to read an csv-file into a string with the Windows-Functions?

which offers several upgrades to WinFile.  If you are trying to read a CSV file and obtain every line, I suggest using the "ReadWholeFile' function and doing the parsing internally instead of relying on "ReadLineFromFile" which cause a system crash.

Hi. Thanks for the info. I will check everything myself.

Reason: