Amongst all the functions listed the OrderSelect is the most confusing. Answers range from time of sending to alphabetical order. I would like to know it from someone who knows it for sure how it works.
Here is the scenario. EA has opened 10 pending orders across 5 charts(2 pending orders per chart). And lets say now i want to modify one my existing orders. The million dollar question what is the most efficient and reliable way of selecting between orders. And what if there are multiple EAs (one EA per chart instead of one EA for 5 charts) running how does one EA differentiate its orders from the others?
Ok worked with that. Another doubt what does it mean mean i specify my magic number as 0 and expiration as 0 while sending a pending order? it is randomly allot a magic number and no expiration respectively?
And in what format is time stored? i mean if i do TimeCurrent()-OrderCloseTime() what would i get. will it be a value in seconds?
1. Thanks got it. So here is what i am doing. Somebody posted a nice way to assign magic number to an EA. magic = makeMagicNumber(WindowExpertName() + Symbol() + Period());
2. So the difference is indeed in seconds :)
I believe that the quickest way to access an order if you know which one you want is to store the ticket number in a variable, something like this :
else Print("Error selecting pending BuyLimit"+GetLastError());
// then you can select by ticket number ie.
if(OrderStopLoss()==0) // no stop set yet
// the ticket will change if the order is filled and the order will be an OP_BUY then.
This way you don't need to loop trough all orders to find the one you need (if it is still pending).
And if the order is still pending, you will find it regardless if you have an EA on each symbol or a single EA for 5 symbols.
Not sure if I explained it properly . Just my 2 cents.And for this example you don't need magic number either but you will
end up with 10 variable, one for each order.
To add comments, please log in or register