MQL4: How to Get All Open Orders for Forex Trading

2 min read

The orders/” title=”Move Stop Loss: MQL4 Code for Sell & Buy Orders”>MQL4 language is a powerful tool for forex traders, as it allows the user to easily access key information such as open positions and orders. In this article, we will discuss how to access all open orders in MQL4. We’ll explain the simple steps needed to get a full overview of your trades and how this information can be used to aid your trading decisions. Furthermore, we’ll also explore how order updates are monitored with this language. To get a list of all your open orders in MetaTrader 4, you can use the OrderSelect() function in an MQL4 script.

This function will go through each open order and store the information in a variable or array.

To get information on each order, you can then use the OrderTicket() function to get the order ticket number, time, type, size, stop loss, take profit, etc.

For reference, here is an example of an MQL4 script that you could use to get all your open orders:

int ticket;
int i;
int count;

count=OrdersTotal();

for(i = 0; i < count; i++){ ticket = OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() == ORDER_TYPE_BUY){ Print(OrderTicket() + “, ” + Time_Current() + “, Buy, ” + OrderLots() + “, ” + OrderOpenPrice() + “, ” + OrderStopLoss() + “, ” + OrderTakeProfit()); } else if(OrderType() == ORDER_TYPE_SELL){ Print(OrderTicket() + “, ” + Time_Current() + “, Sell, ” + OrderLots() + “, ” + OrderOpenPrice() + “, ” + OrderStopLoss() + “, ” + OrderTakeProfit()); } }

You May Also Like

More From Author