Get Price of Last Traded Order

 

Dear all,


So i'm pretty new to MQL5 and are trying to learn the language,


What i'm trying to do is that i have pending orders with SL and TP being executed OnInit()


What i needed is that if the pending order were closed due to hitting SL, i want to retrieve the price of that particular order.


so i tried this in the strategy tester


void OnTrade(
   const MqlTradeTransaction&    trans,        // trade transaction structure
    const MqlTradeRequest&          request,      // request structure
    const MqlTradeResult&           result        // result structure
    )
  {
Alert(trade.RequestPrice());
     }

but it return only the LAST order when it ran.


Say i have 5 pending orders

Order NumberPriceSLTP
 11.0231.0131.063
 21.0331.0231.063
 31.0431.0331.063
 4 1.053 1.043 1.063
 5 1.063 1.053 1.063


So i only get 1.063 even if Order Number 3 (Priced at 1.043) was closed due to stop loss.

Any Help ?