Cycle Operator 'for' questions - page 2

 
WhooDoo22:

Simon,

I do not see what it is you are seeing but ;) I will promptly include the GetLastOrder() function to shed some illumination on this issue. Apologies for posting a question without first including the GetLastOrder() function with the code.

Thank you.

What ticket number does OrderPrint() show ?  what error is shown ?
 

Simon,


what error is shown ?

unknown ticket 2 for OrderClose function


What ticket number does OrderPrint() show ?

#20526942 2012.12.24 13:43 buy 0.01 USDJPY 84.466 0.000 0.000 86.105 0.00 0.00 19.03 0


Thank you.

 
So your USDJPY ticket number is  20526942  and yet you are trying to close ticket NUMBER  (not position)  2  ?  do you see the problem ?
 

Simon,

USDJPY ticket number is 20526942.

The OrderClose() function is attempting to close ticket number 2.

USDJPY ticket number is 20526942 and it's position number in the pool is 2.


If my understanding is correct, The OrderClose() function cannot close the USDJPY order because the first OrderClose() function parameter is using position number 2 instead of the "unique number of the order ticket" (20526942). If you confirm this statement, then I it seems I must find a way to isolate the ticket number 20526942 of the USDJPY order, then place this number in the OrderClose() function's first parameter.

What say you to this? ;)

Thank you.

 
WhooDoo22:


If my understanding is correct, The OrderClose() function cannot close the USDJPY order because the first OrderClose() function parameter is using position number 2 instead of the "unique number of the order ticket" (20526942). If you confirm this statement, then I it seems I must find a way to isolate the ticket number 20526942 of the USDJPY order, then place this number in the OrderClose() function's first parameter.

What say you to this? ;)

Yup,  and there is a function to do just that . . .
 

Simon,

Ya' don't say? ;)

It couldn't possibly be the inconspicuous OrderTicket() function could it? Hahaha.

Thank you.
 
WhooDoo22:

Simon,

Ya' don't say? ;)

It couldn't possibly be the inconspicuous OrderTicket() function would it? Hahaha.

Thank you.
LOL  :-)  your code should work now . . . .   next see if you can modify it to handle multiple USDJPY orders . . .   ;-) 
 

Simon,

Once again, I am so, so abundantly blessed to receive yet another more than generous contribution from the 'Experts' tab in my MetaTrader which I greet with open arms and an exceedingly joyous manifestation. ;)


Error description:

USDJPY price error (OrderClose() function)


Thank you.

 
WhooDoo22:

Simon,

Once again, I am so, so blessed to receive yet another generous contribution from the 'Experts' tab in my MetaTrader which I greet with open arms and an exceedingly joyous manifestation. ;)

Now you need you error reporting so you know exactly what error was generated . . .   it's probably that price is too close to SL or TP to close the order.  What is your  FreezeLevel ?
 

Simon,

MODE_FREEZELEVEL33Order freeze level in points. If the execution price lies within the range defined by the freeze level, the order cannot be modified, cancelled or closed.


I do not know what the freeze level is for the MetaTrader broker I use to run tests. I assume the freeze level varies by broker.

Do you know of a way I can use to discover the MetaEditor freeze level using the MarketInfo() function?

I have already incorporated the GetLastError() function to no avail. I am trying to place it in the correct location at this time.

Also, the current price of the order should well exceed the freeze level.

Here is a snapshot showing its status:

USDJPY order status


Thank you.

Reason: