GetOrderTakeProfit

Returns the take profit level of the currently selected order.

Syntax

GetOrderTakeProfit(): number

Return Value

Returns a number representing the take profit price level of the selected order.

Description

The GetOrderTakeProfit method returns the take profit price level that was set for the currently selected order. The take profit is a price level at which the order will be automatically closed to secure profits when the market reaches that level.

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

Example

// Select an order by ticket number
if (this.api.SelectOrder(12345, EOrderSelectMode.SELECT_ORDER_BY_TICKET)) {
  // Get the order details
  const symbol = this.api.GetOrderSymbol();
  const type = this.api.GetOrderType();
  const openPrice = this.api.GetOrderOpenPrice();
  const stopLoss = this.api.GetOrderStopLoss();
  const takeProfit = this.api.GetOrderTakeProfit();

  console.log(`Order #12345 on ${symbol}:`);
  console.log(`- Type: ${type === TTradePositionType.BUY ? "Buy" : "Sell"}`);
  console.log(`- Open Price: ${openPrice}`);
  console.log(`- Stop Loss: ${stopLoss}`);
  console.log(`- Take Profit: ${takeProfit}`);

  // Calculate potential profit in pips
  const potentialProfitPips =
    type === TTradePositionType.BUY
      ? (takeProfit - openPrice) * 10000
      : (openPrice - takeProfit) * 10000;

  console.log(`- Potential Profit: ${potentialProfitPips} pips`);
}

Notes

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

Last updated