Login Page - Create Account

Support Board


Date/Time: Mon, 16 Sep 2024 19:16:57 +0000



Post From: Error with Sim Lock & Orders being executed

[2024-07-03 17:12:46]
ForgivingComputers.com - Posts: 929
As has been stated, you cannot flatten or cancel after you lock trading.

Something else to consider is to avoid errors. You don't want to flatten if already flat, and you don't want to cancel orders if none exist, as these will cause errors with the trading service.

So, check that orders exist before canceling, and check that there is a position before flattening.

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