clean/reset/refresh OrderSelect results/variables/values??

 

Hi,

I wonder if there is any function or a smart way to clean everything that was retrieved/cached by OrderSelect() or any other function ?

Something similar to RefreshRates(), something that will make me sure that next time I call OrderSelect it will return correct data and that in OrderTicket() for example I won't receive Ticket number of previous OrderSelect() call.

Tried to search on the net and forum but without results.

Thanks in advance

 
OrderTicket will NEVER return a ticket from the previous call. Always check return codes, Always count down.
    for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol() ){              // and my pair.
 
WHRoeder:
OrderTicket will NEVER return a ticket from the previous call. Always check return codes, Always count down.


Thanks for reply. However I just asked if there is a way to reset the OrderTicket()'s value.

Anyways a source code (or at least detailed explanation) of OrderSelect() and it's dependencies would make my life so much easier..

 
  1. lukins:
    if there is a way to reset the OrderTicket()'s value.
    Call OrderSelect
  2. detailed explanation) of OrderSelect()
    My understanding: Every time an order changes (opens, closes, is modified, etc) a list of all orders (all pairs) is sent to the terminal and remembered. OrderSelect probably just makes a copy of the entry is being used and OrderTicket just returns the ticket number for that entry. Same thing for history, it just selects the other list.

    It is always possible that while the EA is running an order will close. I've seen (in the tester but only at max speed,) the orderSelect loop finds my order but the market should have triggered the SL. When that happened the EA tried to close the order but received an invalid ticket. A race condition between the EA and the server. Now I wait until one pip below SL instead of at or below.

 

WHRoeder:

My understanding: Every time an order changes (opens, closes, is modified, etc) a list of all orders (all pairs) is sent to the terminal and remembered. OrderSelect probably just makes a copy of the entry is being used and OrderTicket just returns the ticket number for that entry. Same thing for history, it just selects the other list.


So do you think that OrderSelect really connects to the server each time you call it?

I think that the copy of the entries is SYNCED after login and maybe once per N time, or when there are any changes in the orders on server side..

If that is true, what I need is to find a way to clean that local copy of orders history, or to force Terminal to retrieve all the Orders History from server for current AccountNumber() Account..

 
  1. lukins:
    So do you think that OrderSelect really connects to the server each time you call it?
    No, it's just reading an internal buffer
  2. lukins:
    I think that the copy of the entries is SYNCED after login and maybe once per N time, or when there are any changes in the orders on server side..
    Synced and when server side changes
  3. lukins:
    If that is true, what I need is to find a way to clean that local copy of orders history, or to force Terminal to retrieve all the Orders History from server for current AccountNumber() Account..
    There is nothing to clean or force. The list is up to date subject to your history setting (history tab -> right click -> history setting (all, monthly, custom) Note in the tester there are NO history records to start with.
 

WHRoeder:

There is nothing to clean or force. The list is up to date subject to your history setting (history tab -> right click -> history setting (all, monthly, custom) Note in the tester there are NO history records to start with.


I definitely have to clean or to force. My Script runs through multiple Accounts and collects history data for each one by Logging in one by one. Sometimes (more or less once out of 100 login iterations) OrderSelect(0, SELECT_BY_POS) may select ticket that relates to previously logged in Account while AccountNumber() returns account number of currently logged in account.

So I have to clean the local data before each next login or to force history data retrieval from the server by current AccountNumber() in order to avoid this bug.. Don't you agree with me?


P.S. Probably if I would know how OrderSelect() and AccountNumber() functions are exactly retrieving the data I would already come up with a solution..

Reason: