OrderType()

 
Please help

How can I write into the EA, an instruction for the program to "see" the type of the last position.

for example, if i load the EA into MT and the last position in the account was long then do one thing(A), if the last position was short then do another(B)
 
Paul,

just look at the MACD sample that comes with Metatrader. It looks through all orders and sets the limits based on the order type. To see the last one you'll need to go through the loop and look for the index with the latest order date.


Markus
 

Paul,

just look at the MACD sample that comes with Metatrader. It looks through all orders and sets the limits based on the order type. To see the last one you'll need to go through the loop and look for the index with the latest order date.


Markus


Yes, but does it look at the historical Positions? or the positions currently open?
 
It looks at the open ones. But if you change OrderTotal() to HistoryTotal() and use change MODE_TRADE to MODE_HISTORY in the OrderSelect() statement you can go through the historic ones as well.


Markus
 

It looks at the open ones. But if you change OrderTotal() to HistoryTotal() and use change MODE_TRADE to MODE_HISTORY in the OrderSelect() statement you can go through the historic ones as well.


Markus


This doesnt doit, i tried the first case, and it workes, but histrical id doesnt
 
I am also looking for similar code. I believe the function for selecting the last closed order is:

OrderSelect(1,SELECT_BY_POS,MODE_HISTORY)

can anyone verify this?
 
I also have similar problems, I think the problems are due to the upgrade to Build 186, my EA works perfectly in Build 184.
Perhaps there is a bug in the function OrderSelect() and/or OrderClose().