onTester customFunction

 

Hello,

i have a problem with custom max optimization of the onTester(). In particular, i need a function in the ontester that return the final value and not the maximum calcultaed into the "simulation". I try to explain better with an example. 

this is my onTester() function:

 

double OnTester()

{

   double ret=0.0;

   HistorySelect(0,TimeCurrent());

   for (int i=0; i<HistoryDealsTotal(); i++){

      int idPos=HistoryDealGetTicket(i);

      double open_price=HistoryDealGetDouble(idPos,DEAL_PRICE);

      ENUM_DEAL_TYPE pos_type=HistoryDealGetInteger(idPos, DEAL_TYPE); 

      if(pos_type==DEAL_TYPE_BUY)   ret+=open_price;

      if(pos_type==DEAL_TYPE_SELL)  ret-=open_price;

   }   return(ret);

  } 

 

if i use this code with custom max, it returns the maximum value but actualy i need the value at the end that it's different from the max one.

 How can i solve this problem?

Any ideas?

 

thanks

 

Silvia 

 
silvia.testa:

Hello,

i have a problem with custom max optimization of the onTester(). In particular, i need a function in the ontester that return the final value and not the maximum calcultaed into the "simulation". I try to explain better with an example. 

this is my onTester() function:

 

double OnTester()

{

   double ret=0.0;

   HistorySelect(0,TimeCurrent());

   for (int i=0; i<HistoryDealsTotal(); i++){

      int idPos=HistoryDealGetTicket(i);

      double open_price=HistoryDealGetDouble(idPos,DEAL_PRICE);

      ENUM_DEAL_TYPE pos_type=HistoryDealGetInteger(idPos, DEAL_TYPE); 

      if(pos_type==DEAL_TYPE_BUY)   ret+=open_price;

      if(pos_type==DEAL_TYPE_SELL)  ret-=open_price;

   }   return(ret);

  } 

 

if i use this code with custom max, it returns the maximum value but actualy i need the value at the end that it's different from the max one.

 How can i solve this problem?

Any ideas?

 

thanks

 

Silvia 

You are adding (or substracting) open price of deals, that doesn't make much sense in my opinion.

the value at the end that it's different from the max one.

It's not clear at all. The value of ? Open price ?  Different from the max, which maximum ? Open price too ?

 

In the next picture, there is the result of an optimisation. As you can see the result of optimisation with my custom max function is equal to a profit of 252.10. 

 

But, if i run the test with the same parameters, I obtains a loss of -85. 

The result in the first line of the table is the maximum of the balance in the second picture (not the final one).   

 

Result after optimisationBalance and equity (first combination of parameters in the previous optimisation)

 

 

 

 

 

Reason: