OPENING AND CLOSING TRADE TUTORIAL

In this tutorial, you will learn the details of the transaction process.
How to open, close the trade and get transaction status of this transactions.
The main purpose of this tutorial is to explain the meaning of all order numbers that are connected to this process.
For more info, please refer to the documentation: developers.xstore.pro/api/documentation

As we can see, the order number from TradeTransactionStatus Command is equal to the order2 field in the response of GetTrades command. This because the TradeTransactionStatus returns the number of the order that opened the position, and the order2 in the response of GetTrades command also points to this data. What is more, for opened trades, the order and position numbers are the same and they refer to the number of the position.

Now we have all data needed to close the transaction in the tradeRecordToClose object of the TradeRecord class.

Step 5. Close the transaction

Create an TradeTransInfoRecord with trade data, using data from tradeRecordToClose record from the previous step:

tradeRecordToClose.Close_price

tradeRecordToClose.Symbol

tradeRecordToClose.Order

Execute the TradeTransaction command using created TradeTransInfoRecord