Download MetaTrader 5

best optimized code to get last order in history

To add comments, please log in or register
WESTSUN
8
WESTSUN  

Hi guyz

This  is a piece of my code

bool ordtype;
   for(int vou=0;vou<OrdersHistoryTotal();vou++)
     {
      OrderSelect(vou,SELECT_BY_POS,MODE_HISTORY);
      if(OrderType()==OP_BUY){ordtype=TRUE;}else{ordtype = FALSE;}
     }

 but i think its not optimized, i think its start from the 1st trade and count them one by one until get the last one and do the job.

all i need is the last order type. how i should stop it and directly select the last one in history?

thanks 

whroeder1
15582
whroeder1  
The order of trades in history is not sorted, You must find the last one buy comparing it's timestamp. See also Could EA Really Live By Order_History Alone? (ubzen) - MQL4 forum
WESTSUN
8
WESTSUN  

sorry i'm newbie in mql and programming. and i don't get the conversation out there.

what is the fastest way  to get the last closed order type?

thanks 

Fernando Carreiro
2202
Fernando Carreiro  
WESTSUN:

what is the fastest way  to get the last closed order type?

The fastest way, is to hire someone to code it for you at the Freelance section.

The cheapest way, is to learn how to code it properly, which will obviously take time and patience and require a lot of reading and following examples:

To add comments, please log in or register