gathering information from closed orders.(mt4)

 

(mt4)after selecting  the last closed order from he history pool. how do i gather information about the order (order lots, order type, order magic number etc ) and store that information in other variables?.

secondly, how can i effectively select the n'th order (last closed sell order for example )from the history pool using  order type as the key characterisitic