I'm here to learn. what part of this is not always true. I have been unable to get any other order than the last closed order to show using this method no matter how i arrange them in my accounts history ledger. I always assumed that the numbering of the closed orders on the server was done by OrderCloseTime . Enlighten me please.
I just ran your code
int i =OrdersHistoryTotal()-1;
double closingPrice =OrderClosePrice();
05:48:42 Script aaa AUDUSD,H1: loaded successfully
05:48:42 aaa AUDUSD,H1: initialized
05:48:42 aaa AUDUSD,H1: 102.287
05:48:42 aaa AUDUSD,H1: uninit reason 4
05:48:42 Script aaa AUDUSD,H1: removed
As you can see, it was not the last closed trade
As WHRoeder has not posted it yet, I do it Could EA Really Live By Order_History Alone? - MQL4 forum.
Hey thanks guys! This is good info indeed! I just ran that code on several live accounts and it works on most of them just fine. However on one broker it was not working properly. After further investigation it looks like that particular broker's indexing of the orders in history is done by each orders OPENING time instead of it's CLOSING time. Glad you guys brought this to may attention.. many thanks... PipPip ...Jimdandy
p.s ..was wondering why you were getting an unitialization reason of 4.. I always get 0 ..
p.s ..was wondering why you were getting an unitialization reason of 4.. I always get 0 .
I have no idea. I certainly didn't close the chart.
Thanks once again for your input. The way you defined everything is quite easy for me to understand.
Here I am getting something strange though. I am not understanding how it's counting orders and displaying the Tickets.
Actually my plan is to compare the 'BuyOrder_3/SellOrder_3' of the '3 Simultaneous' orders this EA is opening.
The EA opens a New set of '3 Simultaneous' orders when the Last Opened order i.e. BuyOrder_3/SellOrder_3 gets closed.
Now I am trying that the EA will open '3 Simultaneous' order just once when it gets say Buy signal. Then if all the 3 orders
get closed either by SL/TP and the Buy signal is still 'Valid' it will Open only 'One' order instead of 'Three' orders.
That is why I'm trying to access the 'History' and check if that BuyOrder_3/SellOrder_3 got Closed so that I can set a single odersend function there.