Log in

Genetic algorithm for mt4 by klot:LIN_Neuro_GA.mq4

I have found this EA in the net. It is genetally optimized neural net written by klot (the coder of SSA).

However here there is a custom genetic algorithm that is used in the code and the EA does not use the MT4 native genetic algorithm.

The only problem here is that the system does not trade. Why? I do not know. Maybe it is some fool proof defense system. 

The second problem is that the code description is in Russian, maybe some of our Russian speaking friends can translate it.


От EA tests



  • jaguar1637 2718 days ago

    Klot is brillant . His work is phenomenal. 

    Now, our work is to take this GA functionnality and apply on a specific way

    John, This morning, I have a memory of a red fish (3 seconds memoery only lol ;)  => Can you make me remember where you want to apply this genetic algorithm somewhere ?

    After building the Perceptron of PFE weighted by Goertzel Cycle and Trend wave, followed by their extrapolator, I feel ready to continue the BTS quest (donjons and dragons, Am i correct ;) 

  • JohnLast 2718 days ago

    Jaguer we has mentionned somewhere I do not remember where either that you wanted to make alternative genetic algorithm for MT4. I found this on the net and I was thinking "tiens cela peut etre utile".

    In fact you talked you want to make genetic algorithm that can be independent from the mt4 native algorithm. 

    In the MT4 algorithm there is not a way to change its parameters, and it may be wise to do so.

    That is the point to have independent way of genetic algorithm optimization directly in MT4.

  • jaguar1637 2718 days ago

    Lol, I do not remember what I told you

    Some friends named me "memory erased" ;) lol

  • JohnLast 2718 days ago

    Definitely there is fool bloc in the EA. There is a treshold level:

    double      threshold = 0.7;

    This level is so high that it makes impossible to open a trade. As this is not inside the code it makes impossible to modify it unless you have enough knowledge to read the code.

    I think the idea is to prevent those who do not understand it to use it.

    OK the EA opens trades but there are only losses, still I need to understand how to run the genetic optimiser by klot.

    This is:

    bool Optimize = false; // The optimization unlocks the optimization (In the optimization all the weights are stored on the disc after the optimization is over.). After the optimization turn off the optimization. All the weights will be read. (that is the translation).

    This parameter is also internal making impossible to use for someone who does not read source codes.

  • JohnLast 2718 days ago

    Still the lock is closed because I can't make it to optimize, as far as I understand it has to write in a file the weights of the neural net when optimization is true, and when optimization is false it has to read this file.

    See this:

    FileOpen("weightsN.dat", FILE_BIN|FILE_WRITE);  

    FileWriteDouble(handle, ww[i], DOUBLE_VALUE);

    The file should appear at the folder metatrader/experts/files

    But nothing appear.

  • jaguar1637 2717 days ago

    Is there any people able to back test this EA, while the market is closed ?

  • JohnLast 2717 days ago

    The tests are negative there is not a single profitable trade. However I can't optimize the EA, I do not figure out this.

  • blackdog 2717 days ago

    Hi,JohnLast!! after you made in a code optimization to true,just run EA normaly do not optimizes it.

    sorry my English


  • blackdog 2717 days ago

    i mean run EA in a tester mormaly

  • blackdog 2717 days ago

    i just put it to optimize EA ,will see

  • JohnLast 2717 days ago

    And it works!

    I just updated the first post with an image from the in sample results. BIG Thanks blackdog, the key has been unlocked. 

    There is just one another thing: the stops and take profit levels: 10 equals 1 pips in my Metatrader.

    In fact I was optimizing but as the results were meaningless (take profit at 1 pip and stop loss of 1 pip ) I was thinking that the system did not optimize.  When I changed to more realistic values 40 pips for examples the optimization started to work LOL.

    By its characteristics this EA is unique because it incorporates independant optimization routine. I looked at the code it would be possible to alter the genetic optimizer settings.

    I hope we are going using this example to build Particle Swarm Optimization routine.

    The results published above are in sample, just for proof that the EA works. 

  • JohnLast 2717 days ago

    Optimization instructions:

    It appears that still the use of the optimizer is needed to start the optimization process:

    On the first shot are the results for january 2013 on the 4 h time frame before optimization:


    От EA tests

    The I apply the optimization tab as normal optimization but none of the normal optimization parameters is checked and in the code is made optimization to true (in fact I added it as external parameter, because it is worthless to compile every time). The optimization will make only one pass, but this pass is quite long be patient, you can see on the green bar at the bottom of the tester how the optimization progresses.

    In the journal should appear the message: optimization started:

    When the optimization is over you will hear the normal audio signal that optimization is over:

    Optimization stopped

    There were one passes during optimization

    Then I turn the optimization parameter to false.

    And on the same data I run the EA in order to see the  results:


    От EA tests


    Quite a big difference!

    Additional remarks:

    -The parameter treshold is important because it helps to filter out some of the trades. It is worth to make it external parameter. In the example I used the setting 0.05

    -You can use the normal genetic optimizer to optimize the treshold, the take profit and the stop loss.

    I will update the file with the parameters otpimization and treshold as externals so we can change them without compiling the source every time.

  • jaguar1637 2717 days ago

    Did you try the GA w/ PFE ? deos it work too ?

    Bcoz instead of taking the result of the previous function showing the slope, I put instead the PFE values (pfe period = 9 thanks to Luis)

  • JohnLast 2717 days ago

    Not yet I did not have the time. I was focused to deal with the optimization stuff. 

  • JohnLast 2717 days ago

    I took a look a deeper understanding of the code will be necessary. It is enough for today that we made it work. We can tweak this stuff a lot. 


  • blackdog 2717 days ago

    I translated a comments in EA if it helps I can upload a file

  • MBeng 2411 days ago

    Hi all, Did yoy try this EA live? Anyone get aceptable results from it?

    Did you make any changes on it?