[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 375

 
Chiripaha:

I am not prepared to agree. - Because from such a position, the logic of keeping EAs working and calculating both money and positions correct is lost. - This is one. Second. - If my EA is sleeping, for example, for 100 milliseconds, and another one starts working at the same time, then what will happen, that as soon as these 100 milliseconds pass, the other one will have to stop its work... and pass it back to this one in the middle and so on indefinitely... On the other hand. I've seen (not infrequently) in EAs when they send to "sleep" for minutes and many times at each execution block. - Then, if all other owls are not working during this time, it's also somehow wrong. - So the question is quite pertinent. I would like to understand the logic of operation at this point. But I have not come across a detailed explanation in official documents.

But I am ready to agree. Originally, when mql4 appeared, no one has ever thought about multicurrency, or about packs of owls in one terminal. So there is a possibility that this is normal.

Chiripaha:

But out of two evils I would choose the latter. In that case I would just leave the owl I'm sure of. If you don't do it, it's all the same: at least the correctness of recalculations is preserved, although their work is slowed down.

It makes more sense to use multiple signals, i.e. for each symbol a different signal. Then we accumulate as many signals as we need in the array, and everything is traded by one Expert Advisor. Since the logic is the same, why do we need many EAs?

Chiripaha:

The problem is not as trivial as it seems. - The fact is that my experiments have shown that when the "Allow EAs to trade" box is unchecked, the EA's work does not stop - all calculations are performed on every tick. Just transactions of the EA are not sent to the server. But, if these calculations are filled with these "slips" (not quite correctly), then if there are 5-10 of these EAs, then they specifically can slow the execution of the actual EA that is currently trading.

Yes, some programmers place control over permissions to trade and skip owl's work on this basis. But it is not done more often. And if the code is closed, we cannot at all understand whether the operation is braking or not (and which owl exactly). - Now I will poke around this topic on forum search. Something has slowed down.

Apparently yes, this"Allow EA to trade" button only works as intended if the EA code provides for it.
 
Chiripaha:

I am not prepared to agree. - Because from such a position, the logic of keeping EAs working and calculating both money and positions correct is lost. - This is one. Second. - If my EA is sleeping, for example, for 100 milliseconds, and another one starts working at the same time, then what will happen, that as soon as these 100 milliseconds pass, the other one will have to stop its work... and pass it back to this one in the middle and so on indefinitely... On the other hand. I've seen (not infrequently) in EAs when they send to "sleep" for minutes and many times at each execution block. - Then, if all other owls are not working during this time, it's also somehow wrong. - So the question is quite pertinent. I would like to understand the logic of operation at this point. But I have not come across any detailed explanation in official documents.

But out of two evils I would choose the latter. In this case, I would simply leave the owl that I am sure of. If not, all the same: at least the correctness of recalculations is preserved, although their work is slowed down.

The problem is not as trivial as it seems. - The point is that my experiments have shown that if the "Allow EAs to trade" box is unchecked, then the EA will not stop working - all calculations are performed the same way on every tick. Just transactions of the EA are not sent to the server. But, if these calculations are filled with these "slips" (not quite correctly), then if there are 5-10 of these EAs, then they specifically can slow the execution of the actual EA that is currently trading.

Yes, some programmers place control over permissions to trade and skip owl's work on this basis. But it is not done more often. And if the code is closed, we cannot at all understand whether the operation is braking or not (and which owl exactly). - Now I will poke around this topic on forum search. Something has slowed down.

Thanks to Arles for the question, which reminded me and updated me. I was not experienced enough to understand what was written on the subject. I'll do it again now.


Without going into details of processor's code processing let's stop at the common "picture": during Sleep() there is a pause for further processing of this very code (all the rest codes are processed in INDEPENDENT parallel threads).
 
TarasBY:
Without going into details of processor code processing let's stop on a common "picture": during Sleep() there is a pause on further processing of this very code (all the rest codes are processed in INDEPENDENT parallel threads).

Well, there you go... And that's an "ambush". If I understand what I'm saying correctly. - Let me clarify...

If I understood you correctly, Igor, the Expert Advisors are processed not sequentially at all (as I did in my experiments), but in parallel? And, if it is so, it turns out that Arles is right and 2 trades can be opened in parallel if each signal has received the right conditions?

This is why it is important to me - it will help me to organize my work correctly. When you don't understand what's going on and how, you can make a big mistake.
 

Also, at a glance, Sleep() doesn't work in the tester, it's even written somewhere in the documentation...

The start of the EA is done in Start() function with arrival of each tick. If you have a dozen EAs, try to handle the errors, they should show up. If you do a lot of requests to brokerage companies, most likely there will be an error such as "Flow is busy".

Regarding the checkbox"Allow the EA to trade" . Yes, the Expert Advisor works, but only trades are prohibited, see the log, it will say everything.

 

Hello, can you tell me what this script is?

//+------------------------------------------------------------------+
//|                                                        close.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"
#property show_confirm

//+------------------------------------------------------------------+
//| script "close first market order if it is first in the list"     |
//+------------------------------------------------------------------+
int start()
  {
   bool   result;
   double price;
   int    cmd,error;
//----
   if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
     {
      cmd=OrderType();
      //---- first order is buy or sell
      if(cmd==OP_BUY || cmd==OP_SELL)
        {
         while(true)
           {
            if(cmd==OP_BUY) price=Bid;
            else            price=Ask;
            result=OrderClose(OrderTicket(),OrderLots(),price,3,CLR_NONE);
            if(result!=TRUE) { error=GetLastError(); Print("LastError = ",error); }
            else error=0;
            if(error==135) RefreshRates();
            else break;
           }
        }
     }
   else Print( "Error when order select ", GetLastError());
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
alex12:

Hello, can you tell me what this script is?

It says: "Close the first market order if it is the first in the list".
 
alex12:

Hi, could you tell me what kind of script this is?


Alex, this is what it says here:

script "close first market order if it is first in the list"

A script that closes the first market order if it is the first order in the list.

I.e. as I understand from the logic of the code, it is more likely that the first open order will close. If you have, for example, 10 orders open, then order number 1 will close. I.e. the one which was opened first.

 
Chiripaha:

Well, there you go... And that's an "ambush". If I understand what I'm saying correctly. - Let me get this straight...

If I've understood correctly, Igor, the Expert Advisors are not processed sequentially (like I did in my experiments), but in parallel? If it is so, it means that Arles is right and two trades may be opened in parallel, if each signal has received the right conditions?

Why is this important to me - it will help to organise work properly. When you don't understand what's going on and how, you can make a lot of mistakes.

Sergiy, where did you get such a postulate as "All EAs are processed by the terminal sequentially"? - In the age of parallel computing. ;)

I haven't performed such experiments (with determining the order of processing codes of Expert Advisors by the terminal) - my answer is on the level of logic. I simply (without going into details of the terminal's operation) arrange (forced) consecutive processing of Expert Advisors during trade operations. But the most correct answer is my own experience. True, one should not forget to correctly consider the input parameters when setting the experience, in order to correctly process the obtained results. :)

P.S. I read somewhere (from developer), that current build of MT4 can process up to 8 (if I remember correctly) trade orders in parallel, though from "my point of view" it is not clear what is a user terminal - it is regulated by DC server ("at the other end of the wire"). ;)

 
Chiripaha:

...

I.e. as I understand the logic of the code, it is more likely that the first open order will close. If you have, for example, 10 open orders, then order number 1 will close. I.e., the one, which was opened first.


Yes. But only if this first order is a market order. If it is a pending order, nothing will happen.
 
TarasBY:

Sergey, where did you get such a postulate that "All EAs are processed by the terminal sequentially"? - In the age of parallel computing. ;)

I haven't made such experiments (with determining the order of processing codes of Expert Advisors by the terminal) - my answer is on the level of logic. I simply (without going into details of the terminal's operation) arrange (forced) consecutive processing of Expert Advisors during trade operations. But the most correct answer is my own experience. True, one should not forget to correctly consider the input parameters when setting the experience, in order to correctly process the obtained results. :)

That's the point (for the correctness of staging the parameters of the experiment). That's why I'm asking the questions, as I'm unsure of my own abilities and therefore trying to identify - maybe I've done something wrong, if these results diverge. This is more to the point of testing - at times like this, a seemingly well-written program fails and you realise you have to look somewhere.

I got these "experiments" by accident. I wrote programs for parallel work too - I gave up this method now because it did not increase efficiency (it may be realized in other projects). The result was such a thing, that until the first program would not be processed - no data would be obtained - the second one would not start (or, more precisely, would fail). This sequence depended on the window I'd put (i.e. in what order) EA blocks. - Hence, we have concluded that the sequence of windows is important, i.e. Expert Advisors are processed sequentially, not in parallel. And this sequence depends on window numbering in the list of the terminal.

This is the essence of the experience.

But, again, maybe this is an incorrect interpretation of my results. That's why I'm persistently trying to solve this question now, and not only about the "slip".

Reason: