This method is not complicated, but I don't understand your words. If you want to check market trades - then use next code:
int ticket1=0,ticket2=0; int type1=-1, type2=-1; for(int i=OrdersTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS) && OrderSymbol()==Symbol()) { if(ticket1==0){ticket1=OrderTicket(); type1=OrderType();} else if(ticket2==0){ticket2=OrderTicket(); type2=OrderType(); break;} } }
Of course it's not a full code, and it must be changed by your requirements, but I'm really don't sure what you want.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I would like to know the 2 lasts orders to know if have the same type. How can I do it?
The first think to my mind is get the last orderTicket (LastTicket) and get the last order ticket again but only if the order ticket != LastTicket. After that, get the type of each one. This method is complicated I think...but I am pretty sure that someone know how to do it in a better way.
Thank you in advance