Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 406

 

The Expert Advisor is testing fine in the tester in visual mode, but in the optimization is completely slow, although there are only two parameters for optimization and a small period of time, what is the reason for this?

 
vadynik:

The Expert Advisor is testing fine in the tester in visual mode, but in the optimization is completely slow, although there are only two parameters for optimization and a small period of time, what is the reason for this?

Optimization takes much more time than a single test run, even in visual mode. Try increasing the step of parameter changes. Or switch to testing at opening prices.
 
khorosh:

If you don't care that the start function will not start after the function has been started for 30 seconds (and hence the EA will not take any action during that time), then please put sleep.

therefore after 30 sec the start function and all sequential functions will restart with the arrival of one tick ? and will go back to sleep for 30 sec ... am i wrong ? and expert will do all his actions in the same tick ?
 
bergkamp.:
therefore after 30 sec. the start function and all sequential functions will restart with the arrival of a single tick ? and will go back to sleep for 30 sec... am i wrong ?
Yes while sleep is running, the start() function does not end and therefore does not restart.
 
vadynik:


Can the optimiser be slowed down by graphical objects?

And why do the tags still appear if CLR_NONE is set?

There are no graphics when optimizing. Question: "Where, then, do the marks appear???"
 
vadynik:


Can the optimiser be slowed down by graphical objects?

And why if CLR_NONE is set, do the tags still appear?


It seems that if graphical objects are created in an EA, optimization of such an EA is impossible at all. However, I cannot say for sure. At least, my Expert Advisor using trend lines is not optimized. I cannot say anything about labels, I need to have the whole code.
 
khorosh:
Yes, as long as sleep is running, start() does not end and therefore does not restart.
is start() required anyway ?
 
bergkamp.:
is a start-up required anyway ?
It depends on you whether you need it for expert's work or not, I can't see your expert's code. If it's some pipsqueak with penny targets, it might be necessary.
 

There is a function to close all orders, it closes from the last open, please advise how to re-do it so it starts closing from the first open and ends with the last one.


//+------------------------------------------------------------------+
//|                 Закрыть все ордера                               |
//+------------------------------------------------------------------+


double ClossAllOrders ()

{
  int total = OrdersTotal();
  for(int i=total-1;i>=0;i--)
  {
    OrderSelect(i, SELECT_BY_POS);
    int type   = OrderType();

    bool result = false;
    
    switch(type)
    {
      //Close opened long positions
      case OP_BUY       : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), Slippage, Lime );
                          break;
      
      //Close opened short positions
      case OP_SELL      : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), Slippage, Lime );
                          break;

      //Close pending orders
      case OP_BUYLIMIT  :
      case OP_BUYSTOP   :
      case OP_SELLLIMIT :
      case OP_SELLSTOP  : result = OrderDelete( OrderTicket() );
    }
    
    if(result == false)
    {
      Print("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
      Sleep(500);
    }  
  }
}

// End
 
khorosh:

It seems that if graphical objects are created in an EA, then optimising such an EA is not possible at all. But I cannot say for sure. At least, my Expert Advisor using trend lines is not optimized. I cannot say anything about labels, I need the entire code.

This one, too, was not optimized when data are taken from a graphical object, I mean arrows appearing in all variants...