LastOrder – library MetaTrader 4

The header file contains functions for searching last and previous order in the trade pool.

The functions list:

Function
Short description of the function
int get_last_order( int magic, int type = -1, int mode = MODE_TRADES )  get_last_order() returns ticket number of the last order. The function returns -1 value when it havent found last order.
 Arguments: magic – Magic Number ID filtering orders. When 0  it is not used.                                              
 type – type order (buy, sell, sell limit, buy limit, sell stop, buy stop) for filtering orders.
 mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders. 
int get_first_order( int magic, int type = -1, int mode = MODE_TRADES )
get_first_order() returns ticket number of the first order. The function returns -1 value when it havent found first order.
 Arguments: magic – Magic Number ID filtering orders. When 0  it is not used.                                              
 type – type order (buy, sell, sell limit, buy limit, sell stop, buy stop) for filtering orders.
 mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
double order_lots( int ticket, int mode = MODE_TRADES )
order_lots() returns trade volume by ticket number.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
string order_comment( int ticket, int mode = MODE_TRADES )
order_comment() returns string comment of the order by ticket number.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
int order_type( int ticket, int mode = MODE_TRADES )
order_type() returns type of the order by ticket number.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
double order_open_price( int ticket, int mode = MODE_TRADES )
order_open_price() returns open price of the order by ticket number.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
double order_close_price( int ticket, int mode = MODE_TRADES ) order_close_price() returns close price of the order by ticket number.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
datetime order_open_time( int ticket, int mode = MODE_TRADES ) order_open_time() returns open time of the order by ticket number.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
datetime order_close_time( int ticket, int mode = MODE_TRADES )
order_close_time() returns close time of the order by ticket number.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
int close_by( int ticket, int mode = MODE_TRADES ) close_by() returns the trigger of closing the order:by takeprofit (1), by stoploss (-1), manual(0).It is defined based on comment of the order.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
int close_by2( int ticket, int mode = MODE_TRADES ) close_by2() returns the trigger of closing the order:by takeprofit (1), by stoploss (-1), manual(0). It is defined based on the close price and open price of the order.
Arguments: ticket – ticket number of the order.
mode – pool of orders: MODE-TRADES – trade orders, MODE_HISTORY – closed orders.
int orders_count( int magic, int type = -1, string comment = “” )
orders_count() returns the count of the opened orders.
Arguments: magic – Magic Number ID filtering orders. When 0 it is not used.
type – orders type (buy, sell, sell limit, buy limit, sell stop, buy stop) for filtering orders. When -1 is not used.
comment – comment string of the orders. When “” (empty) is not used.
Alternative:  Kaufman AMA with filter - indicator MetaTrader 5


📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks