Problem with simple script.
this error mean - ERR_INVALID_TICKET, but everything with ticket should be ok.
At the point that you call OrderTicket . . what order have you selected ? OrderTicket ("Note: The order must be previously selected by the OrderSelect() function.")
Did your OrderSend work ?
When i insert OrderSelect() betwen two if conditions:
int start(){ if( Close[1]>iBands(NULL,0,10,2,0,PRICE_CLOSE,MODE_LOWER,1)&& Open[1]>iBands(NULL,0,10,2,0,PRICE_CLOSE,MODE_LOWER,1)&& Low[1]<iBands(NULL,0,10,2,0,PRICE_CLOSE,MODE_LOWER,1)&& Open[0]>iBands(NULL,0,10,2,0,PRICE_CLOSE,MODE_LOWER,0)&& OrdersTotal()==0){ OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-50*Point,0); OrderSelect(0,SELECT_BY_POS,MODE_TRADES); if(Close[0]>=NormalizeDouble(0.5*(iBands(NULL,0,10,2,0,PRICE_CLOSE,MODE_LOWER,0)+iBands(NULL,0,10,2,0,PRICE_CLOSE,MODE_UPPER,0)),4)) OrderClose(OrderTicket(),OrderLots(),Bid,3,Red); }}
EA stil doesn't work properly it makes a lot of orders which shouldn't be maid, and OrderClose() doesn't work at all. I know that this is very strange but it's true, i realy need help.
You need to learn to take notice of return values and act accordingly . . read the documentation on each of the functions you are using . . . for example . . OrderSend "Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function."
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
do you actually have an order to select ? what does OrderSelect return ? true or false ?
Hello.
My name is Luke and i'm a beginer in forex and in programming. I wrote a very simple EA:
The problem apears when i want to test it in metatrader. Orders don't close properly i get "OrderClose error 4108". Like i said i'm complete novice and i haven't got any idea how to resolve this issue, any help will be very appreciated.