best optimized code to get last order in history

Back to topics list To post a new topic, please log in or register
avatar
2
WESTSUN 2016.07.02 04:25
 

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 

avatar
12995
WHRoeder 2016.07.02 14:02 #
 
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


avatar
2
WESTSUN 2016.07.02 23:44 #
 

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 

avatar
1211
FMIC 2016.07.03 00:01 #
 
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:

Back to topics list  

To add comments, please log in or register