Obviously, the profit from the first order makes 108 points, whereas that of the second one is 8 points. Although the first order is opened at a smaller amount of lots, it has the larger profit than the second one, namely the profit of the first order is $540 and the profit of the second order is $80. Closing the first order may seem to be preferable, at the first sight, because it has greater profit. However, it is a misthought. It is necessary to examine the possible case scenario to make a correct decision.
The order closing sequence would not matter, if the price were known not to change during the period of orders closing. However, the price may change during the execution of the instruction to close one of the orders. So the order that can bring more loss, at a negative scenario, should be closed first. If the price sinks one point down, the profit of the first order will decrease by $5, whereas that of the second one will do by $10. Obviously, the second order would bring more loss, so it should be closed first. In such a way, the amount of lots has the dominant significance when deciding about order closing sequence. Profitable case scenario cannot be considered here, because trading develops with the trade criteria in the program, and this time the criterion of closing Buy orders has triggered.
You should consider the other order characteristics if it is necessary to choose between two orders with the same amount of lots. For example, you can consider the distance between the current price and the StopLoss value of each order. At the same time, you should analyze which of the orders would bring more loss, in case of fast price moving. The answer is obvious, as well: the one (from both orders that are opened at the same amount of lots) that has its StopLoss level further from the current price.
Thus you can analyze the priority and all the other parameters of orders and compile the priority-oriented list of criteria to consider with when making the decision about closing orders. It is not difficult to identify the criteria that should not be considered. It is open price (and the related profit from order), for example. The amount of money that the trader have at the moment is shown in the Equity column of the client terminal. The source of this value is not important at that, neither it is a result of loss from one ore more orders, nor it is a result of a profit.
All the necessary characteristics of an order can be received using the corresponding trade functions:
|Execution Errors||Any trade operation (OrderSend, OrderClose, OrderCloseBy, OrderDelete or OrderModify functions) can unsuccessfully end for a score of reasons and return either the negative ticket number or FALSE. You can find out the reason of failure by using the GetLastError function. Every error should be processed in its own way. The table below contains the general recommendations.|
|OrderClose||It closes position. It returns TRUE, if the function has ended successfully. It returns FALSE, if the function fails to end.|
|OrderCloseBy||It closes one open position with the other that is opened in the opposite direction for the same symbol. It returns TRUE. if the function has ended successfully. It returns FALSE, if the function fails to end.|
|OrderClosePrice||It returns the close price of the selected order.|
|OrderCloseTime||It returns the time of closing for the selected order.|
|OrderComment||It returns the comment of the selected order.|
|OrderCommission||It returns the calculated commission value of the selected order.|
|OrderDelete||It deletes the previously placed pending order. It returns TRUE, if the function has ended successfully. It returns FALSE, if the function fails to end.|
|OrderExpiration||It returns the date of expiration of the selected pending order.|
|OrderLots||It returns the amount of lots of the selected order.|
|OrderMagicNumber||It returns the identifying ("magic") number of the selected order.|
|OrderModify||It modifies the parameters of the previously opened orders and pending orders. It returns TRUE if the function has ended successfully. It returns FALSE, if the function fails to end.|
|OrderOpenPrice||It returns the open price of the selected order.|
|OrderOpenTime||It returns the opening time of the selected order.|
|OrderPrint||It enters the order information to the journal.|
|OrderProfit||It returns the net profit (without regard to swaps and commissions) of the selected order. It is the unrealized profit for the opened orders and fixed profit for the closed orders.|
|OrderSelect||The function chooses the order to work with subsequently. It returns TRUE if the function has ended successfully. It returns FALSE, if the function fails to end.|
|OrderSend||The main function for opening orders and placing pending orders. It returns the number of the ticket that was assigned to the order by the trade server, or -1, in case of failing to end the operation.|
|OrdersHistoryTotal||It returns the number of closed positions and deleted orders in the history of the current account, loaded to the client terminal.|
|OrderStopLoss||It returns close price of the position when it reaches the loss level (stop loss) of the currently selected order.|
|OrdersTotal||It returns the total number of open and pending orders.|
|OrderSwap||It returns the swap value of the currently selected order.|
|OrderSymbol||It returns the symbol name for the currently selected order.|
|OrderTakeProfit||It returns the close price when it reaches the profit level (take profit) of the currently selected order.|
|OrderTicket||It returns the ticket number of the currently selected order.|
|OrderType||It returns the operation type of the currently selected order.|