Discussion of article "Experiments with neural networks (Part 2): Smart neural network optimization"

 

New article Experiments with neural networks (Part 2): Smart neural network optimization has been published:

In this article, I will 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 as a self-sufficient tool for using neural networks in trading.

Carry out forward testing of the obtained results to find the best three. In my case, the selection criteria are the maximum profit factor and the number of transactions being more than 100:

  • Test interval: from 2021.07.12 to 2022.07.12;
  • Mode: (Every tick based on real ticks);
  • Initial deposit: 10,000;
  • Timeframe: H1;
  • Fixed lot 0.01;
  • Angle EA 4-4-3.

Test 1:

t1

Test 2:

t2

Test 3:

t3

Author: Roman Poshtar

 
Hello,
Nice article, Could you please share mq4 file as well?
I suspect that if we want to develop more complex, there may be more parameters. There is a limitation in the "FileWrite" function, which is defined as "The number of written parameters can be up to 63" only, does anyone have any suggestions?
many thanks
 
Paranchai Tensit #:
Hello,
Nice article, Could you please share mq4 file as well?
I suspect that if we want to develop more complex, there may be more parameters. There is a limitation in the "FileWrite" function, which is defined as "The number of written parameters can be up to 63" only, does anyone have any suggestions?
many thanks

Thanks for your feedback. Unfortunately I don't have a MT4 version.

 
Superb Job!, thank you so much for this contribution and the down to earth explanations, it is actually refreshing to see great practical ideas in action.
 
Eric Ruvalcaba #:
Superb Job!, thank you so much for this contribution and the down to earth explanations, it is actually refreshing to see great practical ideas in action.
Thanks!
 

Roman, 


thanks so much for your hard work! its amazing. 

not sure if its possible considering your times and schedules... is it possible to add a logic to these EA?

so it would take trade on BUY ONLY , SHORT ONLY, BOTH? like the built in feature that MT4 has? couldn't find the builtin global setting in MT5.

I would like to get an extensive backtest but with having this additional logic, as Im trying to have biases for certain amount of time and stay long only , or short only for certain assets.


cheers.

 
Arjang Aghlara #:

Roman, 


thanks so much for your hard work! its amazing. 

not sure if its possible considering your times and schedules... is it possible to add a logic to these EA?

so it would take trade on BUY ONLY , SHORT ONLY, BOTH? like the built in feature that MT4 has? couldn't find the builtin global setting in MT5.

I would like to get an extensive backtest but with having this additional logic, as Im trying to have biases for certain amount of time and stay long only , or short only for certain assets.


cheers.

Thanks for the feedback. Write to ls. Everything is decided.

 

Hi Roman,

This is a great article and I am attempting to thoroughly understand it in anticipation of incorporating it into my existing EA.  I hope you will be releasing further articles on this subject.

First, in your Angle 4-4-4-3.mq5 this test is checked against false

if (FileIsExist(OptimizationFileName)==false){
 whereas in the Original EA 4-4-4-3 it is checked against true

if (FileIsExist(OptimizationFileName)==true){

More importantly, I am a complete newbie regarding DNN's; this is my first exposure to Neural Networks.

my plan is to use multiple strategies for evaluating buy conditions.  Am I correct in assuming that each strategy might need a separate DNN or can the DNN  expanded to provide evaluation of all strategies at the same time?  In thinking about this, it seems that a Risk Reward function is needed to properly evaluate the best strategy to select for specific conditions, e.g. trending or flat markets.  Is what I am considering result in a significantly larger and more complex network?

I have also developed a complex StopLoss function, for which I am considering a second separate instance of the DNN in order to maximize profits.  Is this a better approach to including the inputs into one larger DNN.

Any  comments you may have will be greatly Appreciated


CapeCoddah

 
CapeCoddah #:

Hi Roman,

This is a great article and I am attempting to thoroughly understand it in anticipation of incorporating it into my existing EA.  I hope you will be releasing further articles on this subject.

First, in your Angle 4-4-4-3.mq5 this test is checked against false

if (FileIsExist(OptimizationFileName)==false){
 whereas in the Original EA 4-4-4-3 it is checked against true

if (FileIsExist(OptimizationFileName)==true){

More importantly, I am a complete newbie regarding DNN's; this is my first exposure to Neural Networks.

my plan is to use multiple strategies for evaluating buy conditions.  Am I correct in assuming that each strategy might need a separate DNN or can the DNN  expanded to provide evaluation of all strategies at the same time?  In thinking about this, it seems that a Risk Reward function is needed to properly evaluate the best strategy to select for specific conditions, e.g. trending or flat markets.  Is what I am considering result in a significantly larger and more complex network?

I have also developed a complex StopLoss function, for which I am considering a second separate instance of the DNN in order to maximize profits.  Is this a better approach to including the inputs into one larger DNN.

Any  comments you may have will be greatly Appreciated


CapeCoddah

Hi. You can use the 8-4-3 or 16-4-3 network to expand your strategy. So you can add conditions. To do this, you need to modify the files. The network has 3 output values Sell, Buy and close. I think there is no need to separate buying and selling.

 

Hi Roman,

I started with your code, Angle 4443,  but I soon realized that there is a glaring issue with your assumption of random testing, namely random testing requires a huge data set,namely 10 to 55th power to completely optimize the results.  A 10,000 element data set only has a remote possibility of identifying a decent solution for each of the 55 neurons. But with Genetic optimization, the use of the best results combined with random mutations should provide faster initial identification of good results although  probably not the most optimum. Consequently, I returned to the original work and chose a 4453 network and tried optimizing using EURUSD H4 with the time  period from 2021 01 01 to 2023 01 01.   I obtained some interesting results using my older 4 core cpu.  First the complete run requires 75000 iterations and over 200 hours to complete. but I was able to identify good solutions after only 4 -8 hours, total equity of 2700 to 2900, based on an initial equity of 1000.  In the last run, that ran almost 2 days, the equity reached 3336. I duplicated your test period and achieved new equity of 2788, although your test period was within my optimization period.  I was using the original calculations as they seemed to work best.  However, short gains achieved a 68% wins whereas longs only had about 45%.  IN the last long run, there were 40,500 optimizations with 37,400 trades breaking even or producing gains whereas only 33150 trades produced a loss.

I did not loook at the money management aspect of the Original system.  When I tried your Angle system on H4, the results bere abysmal.  It looked like the stop loss function was failing miserably, probably due to the different time frame.  Nearly all the runs ended with almost all losses.

I now planto run some sensitivity optimizations to see how changing the number of neurons in each layer affects the optimizations and also see how a 3 layer DNN compares to a4 layer one.


CapeCoddah

Reason: