public interface IOrder
| Modifier and Type | Interface and Description | 
|---|---|
| static class  | IOrder.StateIndicates state of the order | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Sends a request to fully close position by market price or cancel entry order. | 
| void | close(double amount)Sends a request to close the position with specified amount, by market price and default slippage. | 
| void | close(double amount,
     double price)Sends a request to close the position with specified amount, price and default slippage. | 
| void | close(double amount,
     double price,
     double slippage)Sends a request to close the position with specified amount, price and slippage. | 
| boolean | compare(IOrder order)Deprecated. 
 use  Object.equals(Object) | 
| double | getAmount()Returns amount of the order. | 
| java.util.List<ICloseOrder> | getCloseHistory()Returns ordered history of order closing. | 
| double | getClosePrice()Returns price at which order was closed or 0 if order or order part wasn't closed. | 
| long | getCloseTime()Returns time when server closed the order | 
| java.lang.String | getComment()Returns comment that was set when order was submitted | 
| double | getCommission()Return position's commission in account currency. | 
| double | getCommissionInUSD()Return position's commission in USD | 
| long | getCreationTime()Returns creation time. | 
| IEntryOrder | getEntryOrder()Returns Entry Order data. | 
| java.util.List<IFillOrder> | getFillHistory()Returns ordered history of order filling. | 
| long | getFillTime()Returns time of the fill | 
| IFinancialInstrument | getFinancialInstrument()Deprecated. 
 use  getInstrument() | 
| long | getGoodTillTime()Returns time when order will be cancelled or 0 if order is "good till cancel" | 
| IEntryOrder | getGroupedEntryOrder()Returns Entry Order data for second order in One Cancels the Other group. | 
| IStopLossOrder | getGroupedStopLossOrder()Returns Stop Loss Order data for second order in One Cancels the Other group. | 
| ITakeProfitOrder | getGroupedTakeProfitOrder()Returns Take Profit Order data for second order in One Cancels the Other group. | 
| java.lang.String | getId()Returns position or entry ID | 
| Instrument | getInstrument()Returns instrument of the order | 
| java.lang.String | getLabel()Returns label | 
| double | getOpenPrice()Returns entry level price for conditional orders in  IOrder.State.CREATEDandIOrder.State.OPENEDstate or price at which order was
 filled for orders inIOrder.State.FILLEDorIOrder.State.CLOSEDstates | 
| IEngine.OrderCommand | getOrderCommand()Returns  IEngine.OrderCommandof this message. | 
| double | getOriginalAmount()Returns original constant amount of the order. | 
| double | getProfitLossInAccountCurrency()Returns profit/loss in account currency | 
| double | getProfitLossInPips()Returns profit/loss in pips. | 
| double | getProfitLossInUSD()Returns profit/loss in USD | 
| double | getRequestedAmount()Returns requested amount | 
| IOrder.State | getState()Returns current  IOrder.Stateof the order | 
| IStopLossOrder | getStopLossOrder()Returns Stop Loss Order data. | 
| double | getStopLossPrice()Returns price of stop loss condition or 0 if stop loss condition is not set. | 
| OfferSide | getStopLossSide()Returns side that is used to check stop loss condition | 
| ITakeProfitOrder | getTakeProfitOrder()Returns Take Profit Order data. | 
| double | getTakeProfitPrice()Returns price of take profit condition or 0 if take profit condition is not set. | 
| double | getTrailingStep()Returns current trailing step or 0 if no trailing step is set | 
| void | groupToOco(IOrder second)Adds this order with specified second order to One Cancels the Other group. | 
| boolean | isLong()Returns true if order is LONG. | 
| boolean | isOCO()Returns whether this order is One Cancels the Other order. | 
| void | setComment(java.lang.String comment)Sets comment for pending orders. | 
| void | setGoodTillTime(long goodTillTime)Sets "good till time" for BIDs, OFFERs and LIMIT orders. | 
| void | setLabel(java.lang.String label)Sets label for entry orders. | 
| void | setOpenPrice(double price)Sets open price for order in  IOrder.State.OPENEDstate or pending part of partially filled order | 
| void | setOpenPrice(double price,
            double slippage)Sets open price for order in  IOrder.State.OPENEDstate or pending part of partially filled order | 
| void | setRequestedAmount(double amount)Sets amount of order in  IOrder.State.OPENEDstate or cancels pending part of partially
 filled order when amount equals to zero is set. | 
| void | setStopLossPrice(double price)Sets stop loss price. | 
| void | setStopLossPrice(double price,
                OfferSide side)Sets stop loss price. | 
| void | setStopLossPrice(double price,
                OfferSide side,
                double trailingStep)Sets stop loss price. | 
| void | setTakeProfitPrice(double price)Sets take profit price. | 
| void | ungroupOco()Removes this order from One Cancels the Other group. | 
| IMessage | waitForUpdate(IOrder.State... states)Blocks strategy thread (with exception of  IStrategy.onMessage(IMessage)) until the order changes it's state value to one of the expectedstates. | 
| void | waitForUpdate(long timeoutMills)Blocks strategy thread (with exception of  IStrategy.onMessage(IMessage)) until the order changes it's state or any order value gets updated. | 
| IMessage | waitForUpdate(long timeoutMills,
             IOrder.State... states)Blocks strategy thread (with exception of  IStrategy.onMessage(IMessage)) until the order changes it's state value to one of the expectedstates. | 
| IMessage | waitForUpdate(long timeout,
             java.util.concurrent.TimeUnit unit)Blocks strategy thread (with exception of  IStrategy.onMessage(IMessage)) until the order changes it's state or any order value gets updated. | 
| IMessage | waitForUpdate(long timeout,
             java.util.concurrent.TimeUnit unit,
             IOrder.State... states)Blocks strategy thread (with exception of  IStrategy.onMessage(IMessage)) until the order changes it's state value to one of the expectedstates. | 
Instrument getInstrument()
java.lang.String getLabel()
java.lang.String getId()
long getCreationTime()
long getCloseTime()
IEngine.OrderCommand getOrderCommand()
IEngine.OrderCommand of this message. 
 After the order fill returns IEngine.OrderCommand.BUY if the order is LONG,
 IEngine.OrderCommand.SELL otherwise.boolean isLong()
getOrderCommand().isLong()long getFillTime()
double getOriginalAmount()
IEngine.submitOrder(String, Instrument, com.dukascopy.api.IEngine.OrderCommand, double)double getAmount()
IOrder.State.OPENED state returns amount requested. For orders in IOrder.State.FILLED
 state will return filled amount. Filled amount can be different from requested amount (partial fill).double getRequestedAmount()
double getOpenPrice()
IOrder.State.CREATED and IOrder.State.OPENED state or price at which order was
 filled for orders in IOrder.State.FILLED or IOrder.State.CLOSED statesdouble getClosePrice()
double getStopLossPrice()
double getTakeProfitPrice()
void setStopLossPrice(double price)
               throws JFException
getStopLossPrice() method will still return old value until server
 will accept this changes.
 
 Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. By default, may not be called on the same order more often than once per second 
 (exact value of max order update per second is sent by server).
 Not applicable for Global accounts.
 
 
  if (order.getState() == IOrder.State.FILLED
          || (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional())
  ) {
      order.setStopLossPrice(order.getOpenPrice() - instrument.getPipValue() * 20);
  }
 price - price to setJFException - when method fails for some reasonvoid setStopLossPrice(double price,
                      OfferSide side)
               throws JFException
getStopLossPrice() method will still return old value until server will accept this changes
 
 Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. By default, may not be called on the same order more often than once per second 
 (exact value of max order update per second is sent by server).
 Not applicable for Global accounts.
 
 
  if (order.getState() == IOrder.State.FILLED
          || (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional())
  ) {
      order.setStopLossPrice(order.getOpenPrice() - instrument.getPipValue() * 20, OfferSide.BID);
  }
 price - price to setside - side that will be used to check stop loss conditionJFException - when method fails for some reasonvoid setStopLossPrice(double price,
                      OfferSide side,
                      double trailingStep)
               throws JFException
getStopLossPrice() method will still
 return old value until server will accept this changes
 
 Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. By default, may not be called on the same order more often than once per second 
 (exact value of max order update per second is sent by server).
 Not applicable for Global accounts.
 
 
  if (order.getState() == IOrder.State.FILLED
          || (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional())
  ) {
      order.setStopLossPrice(order.getOpenPrice() - instrument.getPipValue() * 20, OfferSide.BID, 10);
  }
 price - price to setside - side that will be used to check stop loss conditiontrailingStep - if == 0 then adds stop loss order without trailing step. Should be 0 or ≥ 10JFException - trailingStep is > 0 and < 10 or when method fails for some reasonvoid setLabel(java.lang.String label)
       throws JFException
By default, may not be called on the same order more often than once per second (exact value of max order update per second is sent by server).
  if (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional()) {
      order.setLabel("new_"+order.getLabel());
  }
 label - new labelJFException - if order is not in IOrder.State.OPENED state or new label is null or emptyOfferSide getStopLossSide()
double getTrailingStep()
void setTakeProfitPrice(double price)
                 throws JFException
getTakeProfitPrice() method will still return old value until server will accept this changes
 
 Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. By default, may not be called on the same order more often than once per second 
 (exact value of max order update per second is sent by server).
 Not applicable for Global accounts.
 
 
  if (order.getState() == IOrder.State.FILLED
          || (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional())
  ) {
      order.setTakeProfitPrice(order.getOpenPrice() + instrument.getPipValue() * 20);
  }
 price - price to setJFException - when method fails for some reasonjava.lang.String getComment()
void setComment(java.lang.String comment)
         throws JFException
By default, may not be called on the same order more often than once per second (exact value of max order update per second is sent by server).
  if (order.getState() == IOrder.State.OPENED && order.getOrderCommand() != BUY && order.getOrderCommand() != SELL) {
      order.setComment("new_"+order.getComment());
  }
 comment - comment textJFException - if order is not in IOrder.State.OPENED statevoid setRequestedAmount(double amount)
                 throws JFException
IOrder.State.OPENED state or cancels pending part of partially
 filled order when amount equals to zero is set.
 
 By default, may not be called on the same order more often than once per second (exact value of max order update per second is sent by server).
  if (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional()) {
      order.setRequestedAmount(0); //cancel conditional order
  }
  
  if (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional()) {
      order.setRequestedAmount(order.getAmount() * 2); //double the order amount
  }
 amount - new amountJFException - when:
 IOrder.State.OPENED nor IOrder.State.FILLEDIOrder.State.OPENED and amount is less than the minimum allowed and not 0IOrder.State.FILLED and with getRequestedAmount()==getAmount()IOrder.State.FILLED and the amount is not 0void setOpenPrice(double price)
           throws JFException
IOrder.State.OPENED state or pending part of partially filled order
 
 By default, may not be called on the same order more often than once per second (exact value of max order update per second is sent by server).
 if (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional()) {
     //raise open price by two pips
     order.setOpenPrice(order.getOpenPrice() + order.getInstrument().getPipValue() * 2);
 }
  
 if (order.getState() == IOrder.State.FILLED && order.getOrderCommand().isConditional()
         && order.getAmount() < order.getRequestedAmount()
 ) {
     //change open price for the UNFILLED part
     order.setOpenPrice(order.getOpenPrice() + order.getInstrument().getPipValue() * 2);
 }
 price - price of the opening conditionJFException - when price change failsvoid setOpenPrice(double price,
                  double slippage)
           throws JFException
IOrder.State.OPENED state or pending part of partially filled order
 By default, may not be called on the same order more often than once per second (exact value of max order update per second is sent by server).
 if (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional()) {
     //raise open price by two pips
     order.setOpenPrice(order.getOpenPrice() + order.getInstrument().getPipValue() * 2, 1);
 }
 if (order.getState() == IOrder.State.FILLED && order.getOrderCommand().isConditional()
         && order.getAmount() < order.getRequestedAmount()
 ) {
     //change open price for the UNFILLED part
     order.setOpenPrice(order.getOpenPrice() + order.getInstrument().getPipValue() * 2, 1);
 }
 price - price of the opening conditionslippage - required price slippage. The value of slippage means following:
      Double.isNaN(slippage) == true then no slippage is used
          JFException - when price change failsvoid close(double amount,
           double price,
           double slippage)
    throws JFException
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. Full position close is not allowed for Global accounts. 
   
 
  if (order.getState() == IOrder.State.FILLED) {
       // conditional partial close by price, with default slippage of 1 pip
      double lastBid = history.getLastTick(instrument).getBid();
      order.close(0.003, lastBid - 1 * instrument.getPipValue(), 1);
  }
 amount - closing amount. Can be less than opened amount, in this case partial close will take place. If 0 is provided then all
              amount will be closedprice - required close price. Close will be rejected if no liquidity at this price. This parameter doesn't affect 
              entry (conditional) orders.slippage - required price slippage. The value of slippage means following:
      Double.isNaN(slippage) == true then no slippage is used
          JFException - when called for order not in IOrder.State.OPENED or IOrder.State.FILLED state. 
  And if order is IOrder.State.OPENED, but amount != 0 or price != 0 or slippage ≥ 0void close(double amount,
           double price)
    throws JFException
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. Full position close is not allowed for Global accounts.  
 
 Note: default value of 5 pips slippage is used. To specify custom slippage, or disable slippage at all, please use extended close(...) methods.
   
 
  if (order.getState() == IOrder.State.FILLED) {
      // conditional partial close by price, with default slippage of 5 pips
      double lastBid = history.getLastTick(instrument).getBid();
      order.close(0.003, lastBid - 1 * instrument.getPipValue());
  }
 amount - closing amount. Can be less than opened amount, in this case partial close will take place. If 0 is provided then all
              amount will be closedprice - required close price. Close will be rejected if no liquidity at this price. This parameter doesn't affect 
              entry (conditional) orders.JFException - when called for order not in IOrder.State.OPENED or IOrder.State.FILLED state. 
  And if order is IOrder.State.OPENED, but amount != 0 or price != 0void close(double amount)
    throws JFException
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. Full position close is not allowed for Global accounts.  
   
 
  if (order.getState() == IOrder.State.FILLED) {
      // unconditional partial close
      order.close(order.getAmount() / 2);
  }
 amount - closing amount. Can be less than opened amount, in this case partial close will take place. If 0 is provided then all
              amount will be closedJFException - when called for order not in IOrder.State.OPENED or IOrder.State.FILLED state. 
  And if order is IOrder.State.OPENED, but amount != 0void close()
    throws JFException
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. Not allowed for Global accounts.
   
 
  if (order.getState() == IOrder.State.FILLED) {
      // unconditional close
      order.close();
  }
  
  if (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional()) {
      // cancel conditional order
      order.close();
  }
 JFException - if order is not in IOrder.State.OPENED or IOrder.State.FILLED stateIOrder.State getState()
IOrder.State of the ordervoid setGoodTillTime(long goodTillTime)
              throws JFException
Applicable to orders of state IOrder.State.OPENED. By default, may not be called on the same order more often than once per second 
 (exact value of max order update per second is sent by server).
 
 
 //order "expires" 1 minute after its creation
 if (order.getState() == IOrder.State.OPENED && order.getOrderCommand().isConditional()) {
     order.setGoodTillTime(order.getCreationTime() + TimeUnit.MINUTES.toMillis(1));
 }
 goodTillTime - time when BID, OFFER or LIMIT orders should be canceledJFException - when order is simple market orderlong getGoodTillTime()
void waitForUpdate(long timeoutMills)
IStrategy.onMessage(IMessage)) until the order changes it's state or any order value gets updated.
 All the ticks, bars and other feed elements that platform receives while waiting get dropped.
 
 The method should be used for imminent order updates (e.g., set stop loss, close order). Consequently it should not be used for non-imminent order updates
 like order close on stop loss, conditional order fill, etc.
 The method must not be called from the IStrategy.onMessage(IMessage) method.
 
 
See usage example at waitForUpdate(long, TimeUnit, State...)
timeoutMills - timeout to wait for order state changeIMessage waitForUpdate(long timeout, java.util.concurrent.TimeUnit unit)
IStrategy.onMessage(IMessage)) until the order changes it's state or any order value gets updated.
 All the ticks, bars and other feed elements that platform receives while waiting get dropped.
 
 The method should be used for imminent order updates (e.g., set stop loss, close order). Consequently it should not be used for non-imminent order updates
 like order close on stop loss, conditional order fill, etc.
 The method must not be called from the IStrategy.onMessage(IMessage) method.
 
 
See usage example at waitForUpdate(long, TimeUnit, State...)
timeout - how long to wait before giving up, in units of
        unitunit - a TimeUnit determining how to interpret the
        timeout parameterIMessage waitForUpdate(IOrder.State... states) throws JFException
IStrategy.onMessage(IMessage)) until the order changes it's state value to one of the expected states. 
 If states is empty, any order update will cause the thread unblocking.
 All the ticks, bars and other feed elements that platform receives while waiting get dropped.
 
 The method should be used for imminent order updates (e.g., set stop loss, close order). Consequently it should not be used for non-imminent order updates
 like order close on stop loss, conditional order fill, etc.
 The method must not be called from the IStrategy.onMessage(IMessage) method.
 
 
See usage example at waitForUpdate(long, TimeUnit, State...)
states - a set of expected states. If null or empty - blocks until order changes it's state to any value.JFException - when order is in state that cannot be changed to one of expected statesIMessage waitForUpdate(long timeoutMills, IOrder.State... states) throws JFException
IStrategy.onMessage(IMessage)) until the order changes it's state value to one of the expected states. 
 If states is empty, any order update will cause the thread unblocking.
 All the ticks, bars and other feed elements that platform receives while waiting get dropped.
 
 The method should be used for imminent order updates (e.g., set stop loss, close order). Consequently it should not be used for non-imminent order updates
 like order close on stop loss, conditional order fill, etc.
 The method must not be called from the IStrategy.onMessage(IMessage) method.
 
 
See usage example at waitForUpdate(long, TimeUnit, State...)
timeoutMills - timeout to wait for order state changestates - a set of expected states. If null or empty - blocks until order changes it's state to any value.JFException - when order is in state that cannot be changed to one of expected statesIMessage waitForUpdate(long timeout, java.util.concurrent.TimeUnit unit, IOrder.State... states) throws JFException
IStrategy.onMessage(IMessage)) until the order changes it's state value to one of the expected states. 
 If states is empty, any order update will cause the thread unblocking.
 All the ticks, bars and other feed elements that platform receives while waiting get dropped.
 
 The method should be used for imminent order updates (e.g., set stop loss, close order). Consequently it should not be used for non-imminent order updates
 like order close on stop loss, conditional order fill, etc.
 The method must not be called from the IStrategy.onMessage(IMessage) method.
 
 
 public void onStart(IContext context) throws JFException {
     IEngine engine = context.getEngine();
     IConsole console = context.getConsole();
     context.setSubscribedInstruments(java.util.Collections.singleton(Instrument.EURUSD), true);
          
     //submit order and await its fill data
     IOrder o = engine.submitOrder("order", Instrument.EURUSD, OrderCommand.BUY, 0.001);
     o.waitForUpdate(2, TimeUnit.SECONDS, IOrder.State.FILLED);   
     console.getOut().format("After fill: open price=%.5f, fill time=%s", o.getOpenPrice(), DateUtils.format(o.getFillTime())).println();
     
     //adjust stop loss to be in 5 pip distance from open price and await the assigned SL price
     o.setStopLossPrice(o.getOpenPrice() - 0.0005);
     //wait max 2 sec for SL price to get updated; note that we don't expect IOrder.State change here 
     o.waitForUpdate(2, TimeUnit.SECONDS); 
     console.getOut().format("After SL update: stop loss=%.5f", o.getStopLossPrice()).println();         
     }
 timeout - how long to wait before giving up, in units of
        unitunit - a TimeUnit determining how to interpret the
        timeout parameter.states - a set of expected states. If null or empty - blocks until order changes it's state to any value.JFException - when order is in state that cannot be changed to one of expected statesdouble getProfitLossInPips()
double getProfitLossInUSD()
double getProfitLossInAccountCurrency()
double getCommission()
For global accounts (i.e., IAccount.isGlobal()) returns the accumulated commission
 of the instrument's position that has been accumulated over the current trading session.
 Which means that the value gets reset with every platform reconnect.
double getCommissionInUSD()
For global accounts (i.e., IAccount.isGlobal()) returns the accumulated commission
 of the instrument's position that has been accumulated over the current trading session.
 Which means that the value gets reset with every platform reconnect.
java.util.List<IFillOrder> getFillHistory()
java.util.List<ICloseOrder> getCloseHistory()
boolean isOCO()
void groupToOco(IOrder second) throws JFException
second - second order in OCO groupJFException - if orders can't be added to OCO groupvoid ungroupOco()
         throws JFException
JFException - if order can't be removed from OCO groupIEntryOrder getEntryOrder()
null if order does not contain pending partIStopLossOrder getStopLossOrder()
null if stop loss condition was not specifiedITakeProfitOrder getTakeProfitOrder()
null if take profit condition was not specifiedIEntryOrder getGroupedEntryOrder()
null if order is not in OCO groupIStopLossOrder getGroupedStopLossOrder()
null if order is not in OCO group or stop loss condition was not specifiedITakeProfitOrder getGroupedTakeProfitOrder()
null if order is not in OCO group or take profit condition was not specified@Deprecated boolean compare(IOrder order)
Object.equals(Object)order - to compare with current@Deprecated IFinancialInstrument getFinancialInstrument()
getInstrument()Copyright © 2025. All rights reserved.