Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

LastOrder - library for MetaTrader 4

Views:
11147
Rating:
(35)
Published:
2014.09.09 08:32
Updated:
2017.03.30 13:11
LastOrder.mqh (12.41 KB) view
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

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.

Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/11816

COrdersCounter COrdersCounter

The simple class for counting of the orders with different filters: by symbol of currency, Magic Number, either closed, either opened orders.

RobotiADXwining RobotiADXwining

Expert Advisor work with one hour chart, and is the best robot for now, plays a sound when orders/alarms are executed and multiply positions by 10 when 5 digits is true, trailing stops every tick regardless of Execution Mode.

MTF Inside Bar MTF Inside Bar

A tool to better visualize price action using a higher timeframe.

NetFlows NetFlows

The indicator computes the volume-adjusted flow of a currency considering all currency pairs available on your platform.