GetOrderCloseTime

Returns the closing time of the currently selected order.

Syntax

GetOrderCloseTime(): TDateTime

Return Value

Returns a TDateTime value representing the closing time of the selected order.

Description

The GetOrderCloseTime method returns the date and time when the currently selected order was closed. The time is returned as a TDateTime value.

Before using this method, you must first select an order using the SelectOrder method.

Example

// Select a historical order
if (
  this.api.SelectOrder(
    5,
    EOrderSelectMode.SELECT_ORDER_BY_POS,
    TSearchMode.DATA_MODE_HISTORY
  )
) {
  // Get the order's ticket number
  const ticket = this.api.GetOrderTicket();

  // Get the opening and closing times
  const openTime = this.api.GetOrderOpenTime();
  const closeTime = this.api.GetOrderCloseTime();

  // Calculate the duration of the order (in days)
  const duration = closeTime - openTime;

  console.log(`Order #${ticket} details:`);
  console.log(`- Opened: ${openDate}`);
  console.log(`- Closed: ${closeDate}`);
  console.log(`- Duration: ${duration.toFixed(2)} days`);
}

Notes

  • An order must be selected first using SelectOrder before calling this method.

  • For closed orders, the returned TDateTime value.

Last updated