[Archive] Learn how to make money villagers! - page 721

 
Slovyn:

Who can tell me what the error is?



Trade flow is busy.

You can also put such a construction in the beginning of the init cov:

int init()
{     
   IsExpertStopped = false;
   if (!IsTradeAllowed())  {Comment("Необходимо разрешить советнику торговать");IsExpertStopped = true; return (0);}      
   if (!IsTesting()) 
      { 
        if (IsExpertEnabled()) {  Comment("Советник запустится следующим тиком"); }
        else   { Comment("Отжата кнопка \"Разрешить запуск советников\""); }
      }

It is treated by handling this error when an order is not placed, e.g. like this:

if (error == ERR_TRADE_CONTEXT_BUSY) 
      {
         while (IsTradeContextBusy()) 
         {
            Sleep(1000*11);
         }
      }
 
Roman.:


Trade flow is busy.

It is treated by handling this error when an order is not placed, e.g. like this:


Isn't it a bit long to wait 11 seconds? It's not a server thing, but purely from having a crowd of EAs in one terminal
 
sergeev:

Isn't it too long to wait 11 seconds? It's not a server thing, it depends on the number of EAs in one terminal


Yes, it's rather long, I have it in my opening function...

Correct, please... I'll make corrections myself as well...

In fact, I have the same figure in my other quest:

for example:

 case 0:
      if (BuySell==1)// || LongTrade)
      {
      for (c = 0; c < NumberOfTries; c++) {
         RefreshRates();
         ticket = OrderSend(Symbol(), OP_BUY, pLots, Ask, sp, StopLong(Bid, sl), TakeLong(Ask, tp), pComment, pMagic, pDatetime, pColor);
         err = GetLastError();
         if (err == 0/* NO_ERROR */) break;
         if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break;
         Sleep(5000);
      }
      }
      break;
 
Roman.:


Rather yes, it's a bit much, I have it so scored in my opening fi...

Correct, please... I'll make corrections in mine as well...


your design is essentially wrong...

if (error == ERR_TRADE_CONTEXT_BUSY) 
      {
         while (IsTradeContextBusy()) 

it needs to be reversed

if (IsTradeContextBusy()) 
{
 // здесь выдать предупреждение и не делать торговых операций


and the ideology in the style

i<NumberOfTries

I find unprofessional.

 
sergeev:

your design is essentially wrong

you need to invert


I see - I will make the corrections. Thank you.
 
Roman.:


Trade flow is busy.

You can also put such a construction at the beginning of the init cov:

It is treated by handling this error when an order is not placed, e.g. like this:

A second is all it takes, as long as the requests don't come in a row.
 
Slovyn:

Who can tell me what the error is?

The trade flow is busy. This could mean that:

1) the trade flow is actually busy

2) the flow is not busy at all and "someone" is pretending to be busy.

3) Technical problems that can be solved by contacting STP.


And by the way, this error can occur when sending a single trade order. Often occurs even when a stop is trawled by the terminal.

 

I, for example, have this... 100% will do the operation)

while(IsTradeContextBusy()) Sleep(100);

while(!error)
{
   error=OrderCloseBy(pos1,pos2);
   Sleep(1000);
}
 
OnGoing:
The second is quite enough, as long as the requests are not consecutive.


I see, I did so - the code section from Avalanche to open orders - I traded on the real - there were no questions.

for (int try = 1; try <= NumberOfTry; try++)
   {
      if (!IsTesting() && (!IsExpertEnabled() || IsStopped()))
      {
         break;
      }
   
      while (!IsTradeAllowed()) 
      {
         Sleep(5000);
      }
    
      RefreshRates();
      opentime = TimeCurrent();
      ticket = OrderSend(symbol, cmd, volume, price, SlipPips, stoploss, takeprofit, comment, magic, expiration, clr);
      if (ticket > 0)
      {
         if (UseSound) 
         {
            PlaySound("ok.wav"); 
            break;
         }
      } 
      else
      {
         error = GetLastError();
         if (error == ERR_TRADE_TIMEOUT)
         {
            Sleep(1000*66);
            if (ExistOrders(symbol, cmd, magic, opentime))
            {
               if (UseSound) 
               {
                  PlaySound("ok.wav"); 
                  break;
               }
            }
         }
        
         Print("Error(", error, ") set order: ", ErrorDescription(error), ", try ", try);
         continue;
      }
      
      Print("Error(", error, ") set order: ", ErrorDescription(error), ", try ", try);
      Print("Ask=", Ask, "  Bid=", Bid, "  symbol=", symbol, "  volume=", volume, "  cmd=", GetNameOP(cmd), "  price=", price, "  stoploss=", stoploss, "  takeprofit=", stoploss, "  magic=", magic);
      if ((error == ERR_COMMON_ERROR) || (error == ERR_ACCOUNT_DISABLED) || (error == ERR_INVALID_ACCOUNT) || (error == ERR_TRADE_DISABLED))
      {
         IsExpertFailed = true;
         break;
      }
      
      if ((error == ERR_SERVER_BUSY) || (ERR_INVALID_TRADE_VOLUME) || (error == ERR_MARKET_CLOSED))
      {
         Sleep(1000*300); 
         break;
      }
      
      if ((error == ERR_TOO_FREQUENT_REQUESTS) || (error == ERR_TOO_MANY_REQUESTS)) 
      {
         Sleep(1000*100);
      }
      
      if ((error == ERR_ORDER_LOCKED) || (error == ERR_LONG_POSITIONS_ONLY_ALLOWED) || (error == ERR_TRADE_TOO_MANY_ORDERS)) 
      {
         break;
      }
      
      if (error == ERR_TRADE_CONTEXT_BUSY) 
      {
         if (IsTradeContextBusy()) 
         {
            Sleep(1000*1);
         }
      }
      
      if (error == ERR_TRADE_EXPIRATION_DENIED )
      {
         expiration = 0; 
         continue;
      }
      
      if ((error != ERR_PRICE_CHANGED) && (error != ERR_REQUOTE)) 
      {
         Sleep(1000*7.7);
      }
   }      
}
 

This is what the tester says in the micro real! (cent account)