Problem: Multiple Trades at brokerX - page 2

 

Thank you guys for all your comments. I will try to reply to all of you:

@doshur: No.

@newdigital: -maybe, but it happens with more than just one EA
                    - no
                    - no
                    - yeah well :)

PS: good to see you over here (coming from tsd)

@tonny: no.

@angevoyageur: I only used some of which I only have ex5. But I will look for one of which I can attach the code.

@laplacianlab: uhm....

@snelle_moda:

Thank you for your comprehensive answer. Good to see someone who had this problem and solved it. I will try to add your findings to my code. A timeout is probably a good solution for those "excessive" ticking at my broker.


Before I read those posts, I also tried to uninstall all terminals and reinstall them. That didn't help unfortunately.

 

i wonder if this page helps

https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradesetasyncmode

maybe someone more experience can explain to me about 

SetAsyncMode

Documentation on MQL5: Standard Library / Trade Classes / CTrade / SetAsyncMode
Documentation on MQL5: Standard Library / Trade Classes / CTrade / SetAsyncMode
  • www.mql5.com
Standard Library / Trade Classes / CTrade / SetAsyncMode - Documentation on MQL5
 

I think it is fixed now.

I used snelle_moda's suggestions to solve it.

Making use of the sleep function, right after setting a trade seems to fix the issue.

Documentation on MQL5: Common Functions / Sleep
Documentation on MQL5: Common Functions / Sleep
  • www.mql5.com
Common Functions / Sleep - Documentation on MQL5
 
Klammeraffe:

I think it is fixed now.

I used snelle_moda's suggestions to solve it.

Making use of the sleep function, right after setting a trade seems to fix the issue.

How long do u set in the sleep function
 
doshur:
How long do u set in the sleep function
8 hours at least :-)
 
angevoyageur:
8 hours at least :-)
Not this sleep. LOL. the EA sleep...
 
angevoyageur:
8 hours at least :-)

Haha :D

Right now 1000ms/1s but I don't know if that much is necessary.

 
Klammeraffe:

Haha :D

Right now 1000ms/1s but I don't know if that much is necessary.

snelle_moda mention he is using 350ms
 

350 ms for opening new trades

750 ms for closing existing trades 

 
If the program controlled conditions of buy / sell in each new bar or if it is idle, my solution is ...
//----------------------- COMPRUEBA ENTRADA por nueva vela o no estar operando ----------------
bool confirmEntrada(string simb= NULL, ENUM_TIMEFRAMES marcoTF= PERIOD_CURRENT)
{
   bool resp= !PositionSelect(simb);
   datetime tmpPos= 0, tmpVela= 0;
   int nTrades= 0, interv= 0;
   nTrades= totalTransPosic(simb);       //numero de transacciones en la posición
   if(nTrades>0)
   {
      tmpPos= horaApertPosicion(simb);
      tmpVela= iTime(simb, marcoTF, 0);           //hora apertura vela cero (la actual)
      interv= tmpVela-tmpPos;
      if(interv>0) resp= nuevaVela(simb, marcoTF);
   }
   return(resp);
}

//------------------------------------- NUEVA VELA -------------------------------------
bool nuevaVela(string simb= NULL, ENUM_TIMEFRAMES marcoTmp= PERIOD_CURRENT)
{
        static datetime nuevoTiempo=0;
        datetime horaVela= iTime(simb, marcoTmp, 0);
        bool resp= false;
        if(nuevoTiempo!=horaVela)
        {
           nuevoTiempo= horaVela;
           resp= true;
        }
        return(resp);
}
Best regards from Spain.
Reason: