Download MetaTrader 5

error 141 - ERR_TOO_MANY_REQUESTS - page 3

To add comments, please log in or register

Not sure if this is what your looking for.  This will attempt to open a trade,

       int Cnt, Tt;

       double  Ticket = OrderTicket();

        double TakeProfit = OrderTakeProfit();

        bool Order;

      if(  Your Condtions for opening a BUY)   
       Alert("OPEN BUY"); 
       Alert("Attempt to Open BUY. Waiting for Response..."); 
       while( Order == false )

       TakeTPB = (Bid+35*Point);

       Order = OrderSend(Symbol(),OP_BUY,Lot,Ask,2,TakeTPB,0);          
       Tt = GetLastError();

       if(Cnt > 2)
       {Cnt = 0; return(0);}      
       if (Tt > 0)
       {Order = false; Alert("Break Buy Here!   ",Tt,"   Bid =  ",DoubleToStr(Bid,Digits); Sleep (5999); RefreshRates(); Cnt = Cnt + 1;
        Alert (GetLastError());}
       if (OrderSelect(0, SELECT_BY_POS)==True)
        Alert ("Opened - Buy Order  ",Ticket,"    TP =  ",DoubleToStr(TakeProfit, Digits),"    Ask =  ",DoubleToStr(Ask,Digits),"   Bid =  ",DoubleToStr(Bid,Digits));
        Alert (GetLastError());
        } }      

three times, then quit.

Dominic Gilbert
Dominic Gilbert  

Thanks for your input YellowBeard.

However, as I am now using Stop Orders, I want it to be placed no matter what. Therefore, using an Include file (code is on previous page from the article honest_knave hyperlinked into this thread) allows all EA's to essentially read from the same sheet using GlobalVariables. This include file is called just before OrderSend and checks if TradeContextBusy or not. If it is not, then it'll push through each of my trades (up to 4 per market, 10 markets traded) at a given time. Between each OrderSend I Sleep(100) too to avoid too_many_requests.

 Execution speed is literally the last thing I should be concerned with as it is not a variable to be concerned with. My orders sit a good 50-100 pips above or below current market price.

 Thanks anyway, I see how that can work :)

To add comments, please log in or register