EA reset

 

Hello, I searched in the forum about EA resetting but nothing found.

When my EA finishes work, I want to reset it, EA would work like newly added into the screen. How can this be done?

 
Eggo:

Hello, I searched in the forum about EA resetting but nothing found.

When my EA finishes work, I want to reset it, EA would work like newly added into the screen. How can this be done?

There is always a reset button with external parameters for backtest or forward test.



 
Subgenius:

There is always a reset button with external parameters for backtest or forward test.



Thanks, I didn't see it earlier.

Maybe someone knows what it is the code of this "Reset" button, that I could add it into my program?

 
Eggo: When my EA finishes work, I want to reset it, EA would work like newly added into the screen. How can this be done?
bool    MySelect(int iWhat, int eSelect, int ePool=MODE_TRADES){
    if (!OrderSelect(iWhat, eSelect, ePool)   ) return (false);
    if (OrderMagicNumber() <  magic.number    ) return (false);
    if (OrderMagicNumber() >  magic.number.max) return (false);
    if (OrderSymbol()      != analyze.pair    ) return (false);
    if (ePool != MODE_HISTORY                 ) return (true);
    return(OrderType() <= OP_SELL); //Avoid cr/bal forum.mql4.com/32363#325360
                                    //Never select canceled orders.
}
int     MyOrdersTotal(){
    int count=0;
    for(int iPos = OrdersTotal(); iPos >= 0; iPos--)
      if (MySelect(iPos, SELECT_BY_POS) count++;
    return(count);
}
int start(){
   static int currentCount; int prevCount = currentCount; currentCount = MyOrdersTotal();
   if (currentCount == 0 && prevCount != 0) init(); // Reinitialize all changed 
                                                    // global variables to their
                                                    // initial (on load) values.
   :
 

Hello Eggo!

I need that my EA close all EURUSD trades and finish work at 23:30 hrs. server time and work again at 24:00 hrs.

Do you know how to do it?

I don´t know how to stop it.

Thank you!

Sara

 
WHRoeder:


   if (currentCount == 0 && prevCount != 0) init(); // Reinitialize all changed 
                                                    // global variables to their
                                                    // initial (on load) values.


You may see strange behaviour using this, when the (global) variables are only initialized with declaration, before init(), and in init() not initialized.

For example when you change the chart or timeframe under a loaded ea or indi. The values will be different.

Not necessarily a good practice... - not yours, but this kind of init.

 
szgy74:

You may see strange behaviour using this, when the (global) variables are only initialized with declaration, before init(), and in init() not initialized.

For example when you change the chart or timeframe under a loaded ea or indi. The values will be different.

Not necessarily a good practice... - not yours, but this kind of init.

That problem is because you are modifying globals and not resetting them in init. FIX the code.
 
WHRoeder:
That problem is because you are modifying globals and not resetting them in init. FIX the code.
I do it like this. But not everybody.
Reason: