Help with Code | Informations about Last Order on MQL4

 

Hi Guys !

Can you help me with  a doubts ?

I need informations about Lots of the Last order.

I'm making this:

double bigTicket     = 0;
double lastLotsOrder = 0;
int counter          = 0;

double getLastLotOrder(int MAGICMA_n){

for(int i=0 ; i < OrdersTotal() ; i++){ 
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) 
        break;
        if((OrderMagicNumber()==MAGICMA_n) && (OrderSymbol() == Symbol()) ){
           if(OrderTicket() > bigTicket ){ 
                bigTicket = OrderTicket();
                if(counter      == 0){
                  lastLotsOrder = OrderLots();
             }
           }
    }
return(lastLotsOrder );
}



My objetive in the function getLastLotOrder is return the lot of the last order.

But doesn't working, can you help me? thankssss

 
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Counter is not used; remove it and the if, and simplify:
          if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)
          && OrderTicket()      >  bigTicket ){ 
          && OrderMagicNumber() == MAGICMA_n
          && OrderSymbol()      == Symbol()) 
          ){  bigTicket = OrderTicket(); lastLotsOrder = OrderLots(); }

  3. odilonfx: the function getLastLotOrder is return the lot of the last order. But doesn't working,
    1. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless. The code is fine (except for the next two points.)
    2. Do not assume history has only closed orders. Need to check the type.
                OrderType() == 6, 7 in the history pool? - MQL4 programming forum
    3. Do not assume history is ordered by date, it's not. Last ticket may not be the last closed. What do you mean by "last order?"
                Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum
 

Thank you bro for you answer !

sorry my english !! this not my native language i am learning yet !!

Reason: