ERR_INVALID_TICKET

For large amounts of code, attach it
- RFTM OrderSelect does NOT return a ticket number.
Ticket = OrderSelect (iCompteur, SELECT_BY_POS);
Ok, but now it tells me ERR_INVALID_FUNCTION_PARAMVALUE. Any idea ?int start() { for (int iCompteur = OrdersTotal()-1; iCompteur >= 0; iCompteur--) // Boucle pour vérifier toutes les positions ouvertes ou en attentes { bool Closed = OrderClose (OrderTicket(), OrderLots(), Bid, 1, Red); if (Closed == false) { int ErrorCode = GetLastError (); string ErrAlert = StringConcatenate ("argMode - error: ", ErrorCode, ": "); Alert (ErrAlert); string ErrLog = StringConcatenate ("Ticket:" , MarketInfo (Symbol(), MODE_ASK)); Print(ErrLog); } } return(0); }
If you are going to use OrderTicket(), OrderLots(), etc you need to select the order that they apply to first . . . read the documentation, from OrderTicket() "
Note: The order must be previously selected by the OrderSelect() function. "
nikky:
a little mistake with but it's not important with my problem. I would like to add i took a short order, that's why for the price I wrote Bid.
Once you have selected your order using OrderSelect() you can use OrderClosePrice() as the close price, then you don't need different code for Buys and Sells . . .
a little mistake with but it's not important with my problem. I would like to add i took a short order, that's why for the price I wrote Bid.
Hello,
I'm trying to do simple EA for the moment and i don't understand why the following one doesn't work to close all the positions :
for (int iCompteur = OrdersTotal() - 1; iCompteur >= 0; iCompteur--) // Boucle pour vérifier toutes les positions ouvertes ou en attentes
{
iTicket = OrderSelect (iCompteur, SELECT_BY_POS); // Sélection de chaque position une par une
bool Closed = OrderClose (iTicket, OrderLots(), MarketInfo (Symbol(), MODE_BID), 1, Red);
if (Closed == false)
{
int ErrorCode = GetLastError ();
string ErrAlert = StringConcatenate ("argMode - error: ", ErrorCode, ": ");
Alert (ErrAlert);
string ErrLog = StringConcatenate ("Ticket:", MarketInfo (Symbol(), MODE_ASK));
Print(ErrLog);
}}
it says ERR_INVALID_TICKET. Can anyone tells me why please?