Questions from Beginners MQL5 MT5 MetaTrader 5 - page 132

 
uncleVic:

11110000000000000111111b=> 31457535 (decimal)

prohibition of trade from 00 to 07 hours

trading hours between 08:00 and 20:00

prohibition from 9 p.m. to 11 p.m.

Thank you
 

Probably, it's a dummy question, I'm still not very familiar with mql5 syntax (as well as everything else). Can a function return more than one value, or an array or some other structure?

Something like:

int testfunc(int x, int Y)

{

  z = x + y;

  n =  x * y;

  return(z, n);

}

test = testfunc(5,10);

Print(test.x,test.y);

 
Lone_Irbis:

Probably, it's a dummy question, I'm still not very familiar with mql5 syntax (as well as everything else). Can a function return more than one value, or an array or some other structure?

No, you can describe an array globally and change its values in a function.
 
zfs:
No, the array can be described globally and its values can be changed in a function.
Thanks, I'll give it a try)
 

Please advise how to unsubscribe from the signal and I signed up for the signal one day later, the signal is active in subscriptions, I put a tick to enable subscription in settings, then OK, but again I open the settings and no ticks.

 
Lone_Irbis:

Probably, it's a dummy question, I'm still not very familiar with mql5 syntax (as well as everything else). Can a function return more than one value, or an array or some other structure?

Something like:

Simple (not containing class objects, strings and dynamic arrays) structures can be returned from functions.

 

Thank you, I've managed to solve the problem without arrays - just using global variables without any predefined value (it's always easy to open a door, as always).

However, I have a new, perhaps less typical question: I know that mql5 has all sorts of built-in features for strategy tester control. But I cannot find any of them allowing to handle optimization results in a preliminarily prepared way. Suppose I want to find an average profit value among all results that have all parameter values except for Х which is in some range?

Or is it possible to do this only by hand in Excel? I know how to do it in Excel, if anything. Just there is an idea of a small research (purely for myself, out of interest), for which I would have to dig through a whole mountain of tables in a very routine and identical way, and I want to automate it somehow...

 
Lone_Irbis:

Thanks, I've managed to solve the problem without arrays - just using global variables without any predefined values (the door was open, as always).

However, I have a new, perhaps less typical question: I know that mql5 has all sorts of built-in features for strategy tester control. But I cannot find any of them allowing to handle optimization results in a preliminarily prepared way. Suppose I want to find an average profit value among all results that have all parameter values except for Х which is in some range?

Or is it possible to do this only by hand in Excel? I know how to do it in Excel, if anything. Just there is an idea of small research (purely for myself, out of interest), for which I would have to dig through a whole mountain of tables in a very routine and identical way, and I want to automate it somehow...

Read here: https://www.mql5.com/ru/docs/optimization_frames


And then search the forum for examples of use.

Документация по MQL5: Работа с результатами оптимизации
Документация по MQL5: Работа с результатами оптимизации
  • www.mql5.com
Работа с результатами оптимизации - Документация по MQL5
 
MetaDriver:

Read it here: https://www.mql5.com/ru/docs/optimization_frames


And then search the forum for examples of use.

Yes, I've come across this a few times before, and examples like this. But for some reason, it didn't seem to be exactly what I was looking for. But maybe it's just that I don't know how to make them yet :)

Anyway, it's not relevant yet as long as the unfortunate owl can't be made to work properly...

So the last (I hope, at least) question for the near future is: how to get the opening price of the last order of a position right?

My test owls were not really originally mine, but a recently found one by an unknown author. This owl has initially had such a strange bug: It works properly in the tester but does not get the value of the last order price in the demo.

double FindLastPrice(long PositionID, bool IsSell) {

   int  i = 0, Total;
   long Ticket, OldTicket = 0, PosID, Magic, Type;
   double OrderPrice = 0;

   HistorySelect(0, TimeCurrent());
   Total = HistoryOrdersTotal();  

   for (i = 0; i < Total; i++) {
      Ticket = (int)HistoryOrderGetTicket(i);
      PosID  = HistoryOrderGetInteger(Ticket, ORDER_POSITION_ID);
      Magic  = HistoryOrderGetInteger(Ticket, ORDER_MAGIC);
      Type   = HistoryOrderGetInteger(Ticket, ORDER_TYPE);
      

      if (IsSell) {
         if ((PosID == PositionID) && (Magic == MagicNumber) && (Type == ORDER_TYPE_SELL)) {
            if (Ticket > OldTicket) {
                OrderPrice = HistoryOrderGetDouble(Ticket, ORDER_PRICE_OPEN);
                OldTicket = Ticket;
            }
         }
      }

      else {
         if ((PosID == PositionID) && (Magic == MagicNumber) && (Type == ORDER_TYPE_BUY)) {
            if (Ticket > OldTicket) {
                OrderPrice = HistoryOrderGetDouble(Ticket, ORDER_PRICE_OPEN);
                OldTicket = Ticket;
            }
         }
      }
   }

   if(!OrderPrice) {
         Print("Ошибка ",GetLastError());
         Sleep(5000);
   }
   return(OrderPrice);
}

It generates error 4753 (order not found) and returns zero in the demo (it returns everything as expected in the tester). And this despite the fact that the test Print suggests that it seems to reachHistoryOrderGetDouble processing and even has a Ticket that isn't empty...

 

Tell me, 50 rating $1 every week? Who has 5000 he gets $100 a week?

Reason: