[Archivio] Imparare a fare soldi abitanti del villaggio! - pagina 721

 
Slovyn:

Chi può dirmi qual è l'errore?



Il flusso commerciale è occupato.

Potete anche mettere una tale costruzione all'inizio dell'init cov:

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

Si tratta di gestire questo errore quando un ordine non viene effettuato, ad esempio così:

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


Il flusso commerciale è occupato.

Si tratta di gestire questo errore quando un ordine non viene effettuato, ad esempio così:


Non è un po' lungo aspettare 11 secondi? Non è una questione di server, ma semplicemente di avere una folla di EA in un terminale
 
sergeev:

Non è troppo lungo aspettare 11 secondi? Non è una questione di server, dipende dal numero di EA in un terminale


Sì, è piuttosto lungo, ce l'ho nella mia funzione di apertura...

Corretto, per favore... Farò delle correzioni anche nel mio...

Infatti, ho la stessa cifra nella mia altra ricerca:

per esempio:

 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.:


Piuttosto sì, è un po' troppo, l'ho così segnato nel mio fi...

Corretto, per favore... Farò delle correzioni anche nella mia...


il tuo progetto è essenzialmente sbagliato...

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

deve essere invertito

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


e l'ideologia nello stile

i<NumberOfTries

Lo trovo poco professionale.

 
sergeev:

il tuo progetto è essenzialmente sbagliato

è necessario invertire


Capisco - farò le correzioni. Grazie.
 
Roman.:


Il flusso commerciale è occupato.

Potete anche mettere una tale costruzione all'inizio dell'iniit cov:

Si tratta di gestire questo errore quando un ordine non viene effettuato, ad esempio così:

Un secondo è tutto quello che serve, a patto che le richieste non arrivino in fila.
 
Slovyn:

Chi può dirmi qual è l'errore?

Il flusso commerciale è occupato. Questo potrebbe significare che:

1) il flusso commerciale è effettivamente occupato

2) il flusso non è affatto occupato e "qualcuno" fa finta di essere occupato.

3) Problemi tecnici che possono essere risolti contattando STP.


E a proposito, questo errore può verificarsi quando si invia un singolo ordine di trading. Spesso si verifica anche quando uno stop è trainato dal terminale.

 

Io, per esempio, ho questo... Il 100% farà l'operazione)

while(IsTradeContextBusy()) Sleep(100);

while(!error)
{
   error=OrderCloseBy(pos1,pos2);
   Sleep(1000);
}
 
OnGoing:
La seconda è sufficiente, purché le richieste non siano consecutive.


Vedo, ho fatto così - la sezione di codice da Avalanche per aprire gli ordini - ho scambiato sul reale - non ci sono state domande.

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);
      }
   }      
}
 

Questo è quello che dice il tester nel micro reale! (conto in centesimi)

Motivazione: