Discussion of article "Creating Custom Criteria of Optimization of Expert Advisors" - page 2

 
Karlson:

Are you saying that the code is of the type

if (balance < 3000) ExpertRemove();

doesn't work?

It does. Already got it. it interrupts optimisation but still displays the results, that's why I thought it doesn't work.


Karlson:

But that's not what I said. That such a breakdown (worked before at least) led to genetics leaving in the end.

Karlson: It does.

But if you reset OnTester() results to zero or do as above (assign minus value -777), then genetics can really behave unpredictably, because selection is performed on the results just by the return value of OnTester().

 
the question remains how to remove unnecessary results from the report.

There was such a thing in MT4:

MT4


Surely it can be done with the help of MQL5 tools, since the developers have removed such functions altogether.

Of course, everything can be copied to Excel, but I would like to take advantage of the new platform.

We have solved the limitations - we can do it with ExpertRemove().

What about skipping useless results in the report?

 
sigma7i:

What about skipping useless results in the report?

You can't do it in the standard report, and you don't need to (I'm against it). Make your own report.

Now you can generate a report at the stage of optimisation(https://www.mql5.com/en/docs/optimization_frames) in any format you need.

And soon (hoo-hoo) it will be possible to manage genetics on your own.

 

Excellent.

From my earlier work in the area of Neural Nets and Genetic Algorithms predicting futures I realized the importance of a reasonably straight equity curve.

and wrote some routines to take that into consideration. It really is a measure of the "robustness" of a predictive system.

 
And now I have finally started to test and explore the possibilities. And I agree. A whole new world is open up. It is a very powerful tool. Thanks again for the article
 

Findings doing practical work.

The straightness module is a good start but incomplete. It is possible to get a very good rating with zero profit. So profit has to come in to the equation. Just to add some kind of measure from the total profit

does not work. You could get a very straight line with good value by having some wins in the beginning, some drawdowns in the middle  and some better winnings in the end. It would produce a level straight line with good fit and show some profit. But that is really not what we are looking for.

We really want a regression line wich rises upwards with good fit. So, in order to make the idea of using a regression line with as little deviation as possible the coefficient for the upward slope has to be incorporated into the equation. That is what

we want to see. An upward sloping regression line with good fit. I will make an attempt of incorporate that. Suggestions and assistance are welcome  :-)

 
The value of the custom criteria is shown in the result listing along with the "standard" criteria. Is it possible to create 2 values in the custom criteria? Have not figured out a good way to combine straightness and slope
 

I am trying the CSTS code.

I find this result a bit strange:


Result      Profit   #Trades  Frofit factor  DrawDown    Expected Payoff  Recovery Factor

0.58        1237     84          1.26            12.70            14.74                0.93

0.57        1598     90          1.38             8.69             17.36                1.76


Here is another example

0.61        3175     123        1.33             21.04           25.82                 1.48

0.60        4460     145        1.49             11.32           30.77                 2.56

From all points of view the values for the second line is better!!  But the score is lower

The only thing I can deduce is that there is a penalty on many trades. I would have it the other way around

And as a last point. There seems to be exactly one person interested in this subject.  Me.


Further on this. I made a mistake in my code and it resulted in pending orders not been cleared. It also resulted in only 5 order placed for testing period over 12 month. With a good profit.

This really boosted the optimization result to over 100. Clearly the value of the "average win" was extremely high resulting in this extreme score. Technically it is correct but it is meaningless

in the context of backtesting. How probable is it that long trends like that are represenatative?. So I figured that the number of trades has to be incorporated in the equation in some way.

With some trial and error changing the code I arrived at a method that produces results that I find useful.

changes:

//    CSTS:
   double   tssf=real/teor;
   if(tssf <= 0) return 0;
  
   work = TesterStatistics( STAT_TRADES );
   if( work <= 0) work = 1;
   work = MathSqrt(work/4);
  
   tssf = tssf * work;
   if( tssf < 1 ) tssf = 0;
   if(TesterStatistics(STAT_PROFIT) <= 0) tssf = 0;

   return(tssf);

The original method is probably good to judge a running system but basically useless to base parameters on from a backtest run

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 

Well, here I am again, the lone wolf in this universe  :-)

I have been trying the straightness Custom Criteria trying to get the slope of the calculated straight line into the equation. As is it can give you a very hgh rating on a very feeble profit. Just adding the end profit

into the caculation does not make it any better  In an attempt to add the actual slope into the equation  I changed the code lilke seen below.

It is not a perfect solution but it is closer to what I want to see. Using result together wit balance or profit  works fine for me with this code


//---------------------------------------------------------------------
//      Get value of the optimization result:
//---------------------------------------------------------------------
double  TBalanceSlopeCriterion::GetCriterion()
  {
//      Let's try to calculate the slope of the balance curve:
   double   current_slope=1000.0*this.balance_Ptr.CalcSlope();

//      If it is inclined down:
   if(current_slope<0.0)
     {
      return(-1.0);
     }

   double   temp=this.balance_Ptr.GetCurrentSKO();
   if(temp>0.0)
     {
      
   //   return(this.scale/temp);        //This just returns how well the results adhere to a straight line that could be anything from a level line to a line pointing uppwards
      double temp2 = this.scale/temp;   //   added Ingvar
      
      return(temp2 * current_slope);    // added Ingvar
      
     }

   return(0.0);
  }
 
ingvar_e:

Well, here I am again, the lone wolf in this universe  :-)

I have been trying the straightness Custom Criteria trying to get the slope of the calculated straight line into the equation. As is it can give you a very hgh rating on a very feeble profit. Just adding the end profit

into the caculation does not make it any better  In an attempt to add the actual slope into the equation  I changed the code lilke seen below.

It is not a perfect solution but it is closer to what I want to see. Using result together wit balance or profit  works fine for me with this code


ingvar_e, not so alone, I like too much this area and was surprised with your evolution, because I do believe in this line of thought too.

For instance, for genetic algorithms, you must have a good fitness algorithm, and for sure create an custom criteria aligned to this fitness.

I'm not sure calculate the slope of balance curve is the better way, since we have several other ways, anyway count on me to explore and debate this ideas.