i would try a Sleep() for a few seconds after 2-3 requotes and increasing it after 5-6 not to get "too many requests"
I don't know what is considered too many requests.
But when an OrderClose fails, you should re-select the order before trying again.
Especially after a re-quote, OrderClosePrice will not be current.
I don't know what is considered too many requests.
But when an OrderClose fails, you should re-select the order before trying again.
Especially after a re-quote, OrderClosePrice will not be current.
I'm not gonna argue with you on that because I never investigate it
but IMHO OrderSelect() olds only the index of order pool or order ticket, and changes that occur on OrderClosePrice() doesn't matter (my 2¢)
bool OrderSelect( int index, // index or order ticket int select, // flag int pool=MODE_TRADES // mode );
but of course you have nothing to lose by selecting the order again
but i think that OrderSelect() olds only the index of order pool or order ticket, and changes that occur on OrderClosePrice() doesn't matter (my 2¢)
from the documentation
The OrderSelect() function copies order data into program environment and all further calls of OrderClosePrice(), OrderCloseTime(), OrderComment(), OrderCommission(), OrderExpiration(), OrderLots(), OrderMagicNumber(), OrderOpenPrice(), OrderOpenTime(), OrderPrint(), OrderProfit(), OrderStopLoss(), OrderSwap(), OrderSymbol(), OrderTakeProfit(), OrderTicket(), OrderType() functions return the data, copied earlier.
@ GumRai you were right, just checked it out (with a script i ran), Order must be re-selected, my mistake, sorry.
it's not just about the apology, it's also for the sake of the forum, if some day, someone is gonna search the forum about this...
best Regards
GumRai: But when an OrderClose fails, you should re-select the order before trying again.
Especially after a re-quote, OrderClosePrice will not be current. | You must RefreshRates and then reselect the order for OrderClosePrice to be current. |
GumRai: But when an OrderClose fails, you should re-select the order before trying again. Especially after a re-quote, OrderClosePrice will not be current. | You must RefreshRates and then reselect the order for OrderClosePrice to be current. |
RefreshRates updates the pre-defined variables and arrays
OrderClosePrice is not one of these.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
I hope you are fine. I am having problems processing requotes in my CloseOrder() function. My function tries to close trades in a loop. If the broker sends a requote, the Ea tries again and again until closed.
In theory it should work, however sometimes the broker sends back an error "Many requests" and does not accept any other transaction requests. This is my code:
My question is, how can I keep this loop alive without the broker rejecting my orders for "too many requests"? Should I leave a sleep() period between the OrderClose() calls? If so, how much?
Thanks