string CloseOrder(string& instr[]){ int ticket=StrToInteger(instr[1]); double volume= StrToDouble(instr[3]); int slippage=StrToInteger(instr[4]); if(StringFind(instr[2],"BUY")>-1){ if(!OrderClose(ticket,volume,Bid,slippage,Red)) { return "Error: " + GetLastError(); }else{ return "Order: " + IntegerToString(ticket) + "succesfully close."; } }else{ if(!OrderClose(ticket,volume,Ask,slippage,Red)) { return "Error: " + GetLastError(); }else{ return "Order: " + IntegerToString(ticket) + "succesfully close."; } } }
Is the symbol of the trade that you are trying to close the same as the chart symbol?
If not, you are trying to close a trade of one symbol with the Bid or Ask of a different one.
The same applies to your OrderSends
Is the symbol of the trade that you are trying to close the same as the chart symbol?
If not, you are trying to close a trade of one symbol with the Bid or Ask of a different one.
The same applies to your OrderSends
Hi GumRai,
yes, the chart symbol is EURUSD and the symbol of the order that I try to close is EURUSD
Please edit and use SRC.
Sorry :-)
I've change my post with the SRC tags around my snippet
Hi GumRai,
yes, the chart symbol is EURUSD and the symbol of the order that I try to close is EURUSD
Well, it's a bit difficult to tell as you are referencing various cells in an array.
May I suggest that you simplify things at least for the OrderClose. There is no need to determine whether it is a buy or sell trade.
OrderSelect the ticket, check that it has not closed
Then close it using OrderLots and OrderClosePrice
Well, it's a bit difficult to tell as you are referencing various cells in an array.
May I suggest that you simplify things at least for the OrderClose. There is no need to determine whether it is a buy or sell trade.
OrderSelect the ticket, check that it has not closed
Then close it using OrderLots and OrderClosePrice
No no. Better dema show us the full code, then we will know straight away the problem is.
dema, please show us the full code and we will help you if it is not too hard.
Well, it's a bit difficult to tell as you are referencing various cells in an array.
May I suggest that you simplify things at least for the OrderClose. There is no need to determine whether it is a buy or sell trade.
OrderSelect the ticket, check that it has not closed
Then close it using OrderLots and OrderClosePrice
Thank's for the answer!
I'll try changing my function like this:
string CloseOrder(string& instr[]){ int ticket=StrToInteger(instr[1]); int slippage=StrToInteger(instr[4]); if(OrderSelect(ticket, SELECT_BY_TICKET)) { if(OrderClose(ticket,OrderLots(),OrderClosePrice(),slippage,Red)) { return "Order: " + IntegerToString(ticket) + "succesfully close."; }else{ return "OrderClose Error: " + GetLastError(); } } else return "OrderSelect Error: " + GetLastError(); }
For the SendOrder trouble, have you some suggest for me?
No no. Better dema show us the full code, then we will know straight away the problem is.
dema, please show us the full code and we will help you if it is not too hard.
The other part of my code is insignificant for this trouble, because I'll receive from an external source the instructions for execute operations.
If you ask me what you need to understand the scenario I'll search to explain you
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I'm writing a script that insert and delete orders.
With pending orders it's all right but when I search to insert a market order or close one of it I'll frequently recive error 129 (Invalid price)
I read on the online documentation that kind of error can happen if there has not been the requested open price in the price thread or it has not been normalized according to the amount of digits after decimal point.
so I modify my code like this:
But I'll still recive error 129! :-(
Please, can someone help me to understand what it's wrong in my code?
Best regards
Dema