Last OrderType
- You are trying to read position index one. That will only work when you have two or more orders (opened or pending on any chart).
- You don't want the last position, you want the last on the current chart; use an OrderSelect loop and find it.
Konut:
Hello Folks,
I am trying to get last Ordertype. (MQL4)
Below code only keeps on working when first buy position is opened.
but when first Sell position is opened it always gives 0 regardless of what type of position are opened further.
I have no idea what's going on.
any help would be appreciated.
int sonuc=-1; int total = OrdersTotal()-1; if(OrderSelect(total,SELECT_BY_POS,MODE_TRADES)==false) break; { sonuc=OrderType(); } Print(sonuc); // 0-BUy,1-sell...
Hello Folks,
I am trying to get last Ordertype. (MQL4)
Below code only keeps on working when first buy position is opened.
but when first Sell position is opened it always gives 0 regardless of what type of position are opened further.
I have no idea what's going on.
any help would be appreciated.