MQL4 BASICS - CREATE YOUR OWN AUTOTRADING EXPERT ADVISORS FOR FREE

Order Management in MQL4

Properly managing orders is a fundamental skill for any trader utilizing the MQL4 platform. MQL4 provides a suite of functions to handle, modify, and track orders. This guide will introduce you to some pivotal order management functions.

1. OrderSend()

This is the primary function to open a new trade order.

int OrderSend(string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment, int magic, datetime expiration, color arrow_color);

2. OrderClose()

Used to close an open order.

bool OrderClose(int ticket, double lots, double price, int slippage, color arrow_color);

3. OrderModify()

Modifies the parameters of an existing order, such as Stop Loss or Take Profit.

bool OrderModify(int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color);

4. OrderDelete()

Deletes a pending order.

bool OrderDelete(int ticket, color arrow_color);

5. OrderSelect()

Selects an order for further processing.

bool OrderSelect(int index, int select, int pool);

6. OrderLots()

Returns the number of lots of the selected order.

double Lots = OrderLots();

7. OrderStopLoss()

Returns the stop loss level of the selected order.

double SL = OrderStopLoss();

8. OrderTakeProfit()

Returns the take profit level of the selected order.

double TP = OrderTakeProfit();

9. OrderType()

Gets the type of the selected order (e.g., buy, sell, buy limit, sell limit, etc.).

int type = OrderType();

10. OrderProfit()

Returns the profit of the selected order.

double Profit = OrderProfit();

Conclusion

Mastering order management in MQL4 is crucial for creating efficient and safe trading algorithms. Ensure you understand each function and its implications in a live trading environment.

Click here to return to MQL4 Basics Directory