Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1782

 
Artyom Trishkin #:

Guys, no matter how you want to go about it, if you don't remember the value of the loop index on the last check, then you have a loop running through all the available history. And the more of it, the longer the loop.

not sure.

I have 2 other EAs with similar design of checking profitability and both of them pass the entire history in the tester within 15-20 min.

 
законопослушный гражданин #:

I am not sure.

I have 2 other EAs with the same design of lot check and they both pass the entire story in the tester in 15-20 minutes

Well, it's up to you. I'm not going to argue.

 
MakarFX #:

change the order override

similarly

 
законопослушный гражданин #:

Yeah, any pair.

I use M15 for AUD/USD.

I had the same problem with your indicator (attached)

I found out by elimination method that this thing slows down the process:

Cache the results (in variables). And the cache should be updated if the list of orders has changed. And if nothing has changed, then just return the values from the cache.

 
Artyom Trishkin #:

Guys, no matter how you want to go about it, if you don't remember the value of the loop index on the last check, then you have a loop running through all the available history. And the more there is, the longer the loop takes.

You should always think that there will be a power outage and so on.

An EA from the history should be configured and running at any time.

 
Volodymyr Zubov #:

Always have to think about power cuts and so on...

The advisor from the story should be configured and working at any time.

There is a VPS to keep the lights on.

 
Yes, you don't need a local variable to find the order
 

I understand roughly why there are problems.

Now I want to do the following:

clean up void OnTick

void OnTick()
{
// Получим значение индикатора
   dMA = iMA(Symbol(), 0,PeriodMA, MovingShift, MODE_SMA, PRICE_CLOSE, 0); // MODE_SMA - простое усреднение , значение 0. PRICE_CLOSE- цена закрытия, значение 0.

// Если нет открытых ордеров, то входим в условие
   if(CountOrders()==0)
   {
  
// Если появился сигнал на покупку, то откроем ордер на покупку
      if(bSignalBuy() == true)
         vOrderOpenBuy();

// Если появился сигнал на продажу, то откроем ордер на продажу
      if(bSignalSell() == true)
         vOrderOpenSell();
   }
}

the signal to make it like this:

bool bSignalBuy()
  {
   if (openPrice > Open[1] && openPrice < Close[1]) //Open[1] и Close[1]- цены открытия и закрытия каждого бара текущего графика.
   
  return(true);
   
  return(false);
  }
//+-----------------------------------------------------------------------------------------------+
//|                                                             Функция поиска сигнала на продажу |
//+-----------------------------------------------------------------------------------------------+
bool bSignalSell()
  {
   if(openPrice< Open[1] && openPrice > Close[1])

   return(true);

   return(false);
  }

whereopenPrice tries to express it this way, but it gives out an error:

possible loss of data due to type conversion

am I using void function correctly ?

  void openPrice()
  {
  int OP=0;
  
  if (GetLotSize()>LotControl) OP = dMA + Deviation * _Point;
  else OP = dMA;
  }
 

Made a line follow the mouse cursor after pressing a button through draw and delete

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
  {    
    if(ObjectGetInteger(0,"button_bs",OBJPROP_STATE)){
      int      x     =(int)lparam;
      int      y     =(int)dparam;
      datetime dt    =0;
      double   price =0;
      int      window=0;
     
      if(id == CHARTEVENT_MOUSE_MOVE){
        if(ChartXYToTimePrice(0,x,y,window,dt,price)){
            ObjectDelete(0,"H Line");
            ObjectCreate(0,"H Line",OBJ_HLINE,window,dt,price);
            ChartRedraw(0);
        }
      }
    }
    else{
      ObjectDelete(0,"H Line");
    }
  }

Maybe there is another way? The processor cooler is starting to get noisy :)

 
Volodymyr Zubov #:

Always have to think about power cuts and so on...

An advisor from history should be configured and working at any time.

It should. So, how will remembering the loop index prevent it from going through history after a restart?
Reason: