Login Page - Create Account

Support Board


Date/Time: Fri, 07 Feb 2025 18:05:30 +0000



Post From: ACSIL - Internal Order ID given to sc.ModifyOrder is 0

[2020-06-05 21:48:13]
ForgivingComputers.com - Posts: 996
Your original issue was "Internal Order ID given to sc.ModifyOrder is 0".

You were trying to modify an order price or quantity, and it was getting rejected due to a non-existent order ID.

I recommend you don't look up the order that way. Instead, when the order is filled, you should save a persistent variable of the order id(s):

ParentOrderID = NewOrder.InternalOrderID;

When there are no open orders, you should reset ParentOrderID to 0.

If you want to flatten and cancel any open positions that have no working orders, then this is easier:


s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);
{
  if (PositionData.PositionQuantity != 0 && PositionData.WorkingOrdersExist)
  {
    sc.FlattenAndCancelAllOrders();  
    sc.AddMessageToLog("Open Position with No Working Orders. Position Flattened.", 0);
  }
}