Login Page - Create Account

Support Board


Date/Time: Wed, 05 Nov 2025 14:24:27 +0000



Post From: Autotrader live order modification fails

[2025-09-12 17:33:48]
ForgivingComputers.com - Posts: 1154
When I add an extra line to flatten and cancel everything after trade position is closed, it rejects because the order doesn't exist at rithmic.

When the position is closed due to a stop or target being hit, the "sibling" order (the target or stop respectively) is automatically cancelled. You should not need to do anything after the position is closed.

However, if you do want to Flatten and Cancel (while the position is open) you should pre-check to see if there is a position and/or orders to cancel to avoid an error.

Rule #1: Only send flatten and cancel if there is an open position.
Rule #2: If no Open Position and there are still working orders then Cancel all orders

  s_SCPositionData PositionData;
  sc.GetTradePosition(PositionData);
  
  if (PositionData.PositionQuantity != 0)
  {
    sc.FlattenAndCancelAllOrders();
  }
  else if (PositionData.WorkingOrdersExist)
  {
    sc.CancelAllOrders();
  }