Questions from Beginners MQL5 MT5 MetaTrader 5 - page 186

 
please advise the best signal indicator on this site...as long as it's free of charge of course!
 
barabashkakvn:
And "quite a lot of calculations based on history" add up to a dynamic array?

There is such a thing, yes :) Well, more precisely, several dynamic arrays are used, but they're not supposed to grow to too big a size.

And about splitting in half - it doesn't seem to make much difference which segment to take and how many inputs it has. On average a day is handled in 2500-3500 ms, but a week has to wait a few minutes. Don't have a suitable log handy at the moment, can't be sure how much. But an order of magnitude more than 5x per day, and most of the time is spent on the last day or two. A month, on the other hand, can be left overnight and by morning it will probably still be hanging >.>

 
Lone_Irbis:


And about splitting it in half - it doesn't seem to make much difference which section to take and how many inputs it has.

Include a forward test with a 1 / 2 ratio. It will automatically divide the history into periods. In addition, you will also find out if it is worth it.
 
Lone_Irbis:
I wonder if there's an article somewhere like "the most common reasons for EA sluggishness"? I'm trying to understand why the Expert Advisor in the Strategy Tester is flying at the beginning but slows down further. It is not on the stage of development for it to be that critical (the speed is enough for development of basic mechanisms and tools). But it's still inconvenient that segments longer than a week don't make sense, because after that the speed already tends to zero.

Try putting a barrel of paint on its wheels and sliding it behind you as needed.

https://www.mql5.com/ru/forum/14041/page3#comment_605412

Линейное торможение - ошибка программиста или особенность работы MT4?
Линейное торможение - ошибка программиста или особенность работы MT4?
  • www.mql5.com
Такая работа просто убивает возможность оперативной настройки советника.
 
MetaDriver:

Try putting the paint barrel on its wheels and sliding it behind you as needed.

https://www.mql5.com/ru/forum/14041/page3#comment_605412

It's an interesting parable :) Thanks for the tip. All that remains is to find that particular barrel... Or rather barrels. However, I already have a vague suspicion of news and resistance levels handlers...
 
Lone_Irbis:
It's an entertaining parable :) Thanks for the tip. All that remains is to find the barrel... Or rather barrels. However, I already have a vague suspicion of news and resistance levels handlers...
Most often such a barrel is "the beginning of times" - the Expert Advisor tries to reanalyze its own trading history (or some other accumulated information) at every bar (tick).
 
Recently refocused on creating panels, so my question is. I am creating two labels OBJ_RECTANGLE_LABEL and OBJ_LABEL and don't know how to drag OBJ_RECTANGLE_LABEL on graphic so that OBJ_LABEL is dragged exactly as one. Maybe there is some mechanism of linking them to each other and an action on one will cause the same on the other (all the others)?
 
MetaDriver:
Most often such a barrel is "the beginning of times" - own trading history (or some other accumulated information) an Expert Advisor tries to reanalyze at every bar (tick).

О! Surprisingly enough, the problem was found and fixed in literally minutes. Indeed, the problem was in the trading history, which went over every tick. The function I inherited from the code a la "the simplest Expert Advisor for mql5" that was used in the beginning. It has somehow slipped my mind since then. It seems to be working, so I think - why bother with it... Obviously, I'd better look through the remnants of that code :) Just in case someone Googled here with similar lags, I'll post the problematic fragment and my creative work on the subject in an attempt to solve this problem. I don't know how much more "correct" my version is in relation to the source. Most likely it's exactly the same shitty code as everything else I write. [I, of course, don't care. I mean, if someone will think to use the bottom piece: take into account that author is a self-taught shitcoder. ^^] But at least nothing seems to be broken and robot is flying like a jet :) Well, compared to what it was, at least. Trial two months went by in about a minute, which is still a nice contrast to the original 6+ hours %)

Was:

// Эта функция вызывалась дважды за каждый тик. С ее помощью записывались две глобальные переменные: 
// с ценой последнего ордера и числом открытых ордеров (да, взятый за исходник код был примером самого простейшего мартина). 
double History(bool LastPrice = false){
   long Ticket, OldTicket = 0, PosID, Magic, Dir;
   double PriceOpen = 0, Count = 0;
   ENUM_DEAL_TYPE CheckDir;
   if(Sell) CheckDir = DEAL_TYPE_SELL; 
   else if(Buy) CheckDir = DEAL_TYPE_BUY;
   
   HistorySelect(0, Now);
   int HistoryTotal = HistoryDealsTotal();
   // Проблемное место было тут: в цикле перебиралась вся история торговли, что в начале немного. 
   // Но даже за сутки счетчик доходил до сотни (не рискну предположить, сколько там набиралось за месяц). 
   // И этот бессмысленный и беспощадный процесс повторялся на каждом тике вообще без всякой на то причины.
   for (int i=0; i < HistoryTotal; i++){ 
      Ticket = (int)HistoryDealGetTicket(i);
      PosID  = HistoryDealGetInteger(Ticket, DEAL_POSITION_ID);
      Magic  = HistoryDealGetInteger(Ticket, DEAL_MAGIC);
      Dir    = HistoryDealGetInteger(Ticket, DEAL_TYPE);
      
      if(LastPrice) { // Этой частью добывалась цена
         if(PosID == PositionID && Magic == MagicNumber && Dir == CheckDir) {
            if(Ticket > OldTicket) {
               PriceOpen = HistoryDealGetDouble(Ticket, DEAL_PRICE);
               OldTicket = Ticket;
            }
         }
      }
      
      else { // А тут оно считало ордера
         if(PosID == PositionID && Magic == MagicNumber) Count++;
      }                              
   }
   
   if(LastPrice) return(PriceOpen);
   else return(Count);
}

Became:

// Вызывается она теперь только в конце функций создания/изменения/закрытия позиций. Если открытых нет - глобальные переменные просто обнуляются.
// Хотя в принципе, если вызывать ее не каждый тик, а только на изменениях, вероятно и старая версия не тормозила бы так уж сильно
void History(){
   long Ticket, PosID, Magic, Dir;
   bool GotPrice = false;
   Total = 0;
   HistorySelect(0, Now);
   int HistoryTotal = HistoryDealsTotal();
   
   // Похоже, что быстрее будет считать с обратного конца
   for(int i=HistoryTotal;i>=0;i--){
      Ticket = (int)HistoryDealGetTicket(i);
      PosID  = HistoryDealGetInteger(Ticket, DEAL_POSITION_ID);
      Magic  = HistoryDealGetInteger(Ticket, DEAL_MAGIC);
      Dir    = HistoryDealGetInteger(Ticket, DEAL_TYPE);
      
      if(PosID == PositionID && Magic == MagicNumber) {
         // Корявую конструкцию заменяем на... другую корявую конструкцию... но она хотя бы компактнее :)
         Total++; 
         if(!GotPrice){
            LastOrderPrice = HistoryDealGetDouble(Ticket, DEAL_PRICE);
            GotPrice = true; // Раз уж нужная цена всегда в начале списка, на ней и остановимся
         }
      }
      // Чтобы не перепахивать всю торговую историю, если номер позиции уже меньше нашего (но больше ноля) - прерываем цикл
      else if(PosID > 0 && PosID < PositionID) break; 
   }
}

Anyway, thanks for the help :) Without the tip, it probably wouldn't have occurred to me to look into those far dusty corners of the code for a long time yet...

 
Lone_Irbis:

О! Surprisingly enough, the problem was found and fixed in literally minutes. Indeed, the problem was in the trading history, which went over every tick. The function I inherited from the code a la "the simplest Expert Advisor for mql5" that was used in the beginning. It has somehow slipped my mind since then. It seems to be working, so I think - why bother with it... Obviously, I'd better look through the remnants of that code :) Just in case someone Googled here with similar lags, I'll post the problematic fragment and my creative work on the subject in an attempt to solve this problem. I don't know how much more "correct" my version is in relation to the source. Most likely it's exactly the same shitty code as everything else I write. [I, of course, don't care. I mean, if someone will think to use the bottom piece: take into account that author is a self-taught shitcoder. ^^] But at least nothing seems to be broken and robot is flying like a jet :) Well, compared to what it was, at least. Trial two months went by in about a minute, which is still a nice contrast to the original 6+ hours %)

Was:

Became:

Anyway, thanks for the help :) Without the tip, it probably wouldn't have occurred to me to look into those far dusty corners of the code for a long time yet...

ok.
 
paladin800:
Recently refocused on creating panels, so my question is. I am creating two labels OBJ_RECTANGLE_LABEL and OBJ_LABEL and don't know how to drag OBJ_RECTANGLE_LABEL on graphic so that OBJ_LABEL is dragged exactly as one. Maybe there is a mechanism for binding them to each other and an action on one will cause the same action on the other (all the others)?

There is no such mechanism. You'll have to create one by yourself. Luckily it's not that hard. But it will take some work.

Good luck.

Reason: