Question re: working with orders

How to create strategies and indicators
Message
Author
dackjaniels
Posts: 151
Joined: Tue Feb 24, 2009 1:03 pm

Question re: working with orders

#1 Postby dackjaniels » Fri Mar 20, 2009 4:22 am

Hi,
I am creating a strategy in FT2 and have a question regarding orders.

How can I determine if an order has been closed due to hitting its stoploss?

I tried using the OrderSelect function expecting it to return FALSE if the order in question has already been closed. However it returns TRUE regardless.

The command I used was:

OrderSelect(OrderHandle, SELECT_BY_TICKET, MODE_TRADES)

I assumed once the order hit the S/L and was closed (and hence moved to the History tab of the terminal), that the function would no longer be able to select the order in question and return FALSE. However as I said it always returns TRUE.

In testing I also used the OrderTicket() function and it returns the ticket number regardless of whether the order is still open or not.

The help file seems to say that the OrderSelect MODE_TRADES option limits the order search to the open and pending trades so why is it picking up closed trades (from Trade History)?


Am I missing something here?

Your help is much appreciated.

Regards,
Steve


UPDATE: I just found the OrderClosed() function which has solved my initial problem (Completely missed it in the help file on last search :oops: ). However, I still don't understand why the above OrderSelect function returns TRUE for a closed order when MODE_TRADES is used. Should this not limit the search to those orders that are still open or pending? Thanks.

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#2 Postby Terranin » Sat Mar 21, 2009 11:00 am

Last flag (MODE_TRADES or MODE_HISTORY) is ignored if you search by order ticket. The same situation in MetaTrader, I made it for compatibility.
Hasta la vista
Mike

dackjaniels
Posts: 151
Joined: Tue Feb 24, 2009 1:03 pm

#3 Postby dackjaniels » Sun Mar 22, 2009 9:47 am

Terranin wrote:Last flag (MODE_TRADES or MODE_HISTORY) is ignored if you search by order ticket. The same situation in MetaTrader, I made it for compatibility.


I see, thanks for claryfying this Mike. I never noticed this point in the help file, perhaps a note could be added in a future revision of help.

Regards,
Steve


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 12 guests