close order not working

 

this code looks right to me, but I must be missing something because it will not work...


Open order-


if (OrderSelect(123456,SELECT_BY_TICKET) == false )
{
OrderSend(Symbol(),OP_SELL,1,Bid,3,StopLose,TakeProfit,"Short Open",123456,0,White);
return(0);
}

close open order-


if (OrderSelect(123456,SELECT_BY_TICKET) == true)

{

OrderClose(123456,1,Ask,5,CLR_NONE);

return(0);

}


It opens them ok, but will not close them...

tia for any help

 

Is

OrderSelect(123456,SELECT_BY_TICKET)

true?

 
Yes, if the first part opens an order, the second part will not close it
 

I don't think so. Check again.

 
ok, what am i doing wrong then?
 

You are trying to use the magic number parameter as a ticket number in the closing code.

 
that sounds like it, i though they were the same thing
 

...

...

if (OrderSelect(123456,SELECT_BY_TICKET) == true) Print("Unbelieveable! I found it"); // add this line

if (OrderSelect(123456,SELECT_BY_TICKET) == false) Print("Not found, told you so."); // add this line

if (OrderSelect(123456,SELECT_BY_TICKET) == true)

{

OrderClose(123456,1,Ask,5,CLR_NONE);

...

...

 
wait, so those 2 print lines are all thats missing?
 

No. That is a test.

 
phy:

No. That is a test.

Hi phy,


Can you please help me with this indicator? the arrows will not update and I'm no good at codes. Attached indi. Thanks in advance!!

Files:
wprrdiv.mq4  13 kb