ClosePartialPosition
Syntax
ClosePartialPosition(orderTicket: number, lotSize: number): booleanParameters
Return Value
Description
Example
Last updated
ClosePartialPosition(orderTicket: number, lotSize: number): booleanLast updated
// Select an order by ticket number
if (this.api.SelectOrder(12345, EOrderSelectMode.SELECT_ORDER_BY_TICKET)) {
// Get the order details
const ticket = this.api.GetOrderTicket();
const details = this.api.GetOrderDetails(ticket);
// Close half of the position
const halfLot = details.lot / 2;
if (this.api.ClosePartialPosition(ticket, halfLot)) {
console.log(`Successfully closed ${halfLot} lots of position #${ticket}`);
} else {
console.log(`Failed to partially close position #${ticket}`);
}
}