Login Page - Create Account

Support Board


Date/Time: Mon, 06 May 2024 23:17:47 +0000



Post From: Order.Stop1InternalOrderID = 0 in LIVE trading?

[2019-09-03 06:19:21]
tomas262 - Posts: 135
I am adjusting Stop1Order for a trade open with ACSIL. When using SIM / REPLAY mode everything works great. Once a trade is open Stop1InternalOrderID is set for example to value 14695 so ID is non-zero and order can be modified successfully

But when I switch to live trading and open a trade with the same code Stop1InternalOrderID is always 0 so the order cannot be selected to modify

With the very same code what could be the reason? Trade LIVE & REPLAY screenshot attached

Also attaching executed orders table with IDs shown

This opened the sell trade:

s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = OCO1Size.GetInt() + OCO2Size.GetInt() + OCO3Size.GetInt();
NewOrder.OrderType = SCT_ORDERTYPE_MARKET;
NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;

int Result = (int)sc.SellEntry(NewOrder);
if (Result > 0)
{
  EntryOrderID = NewOrder.InternalOrderID;
  Target1OrderID = NewOrder.Target1InternalOrderID;
  Stop1OrderID = NewOrder.Stop1InternalOrderID;
}

This is how I move to B/E


// Get and move the existing SL 1 order
s_SCTradeOrder ExistingStopOrder1;
if (sc.GetOrderByOrderID(Stop1OrderID, ExistingStopOrder1) != SCTRADING_ORDER_ERROR)
{
  if (IsWorkingOrderStatus(ExistingStopOrder1.OrderStatusCode))
  {
    double NewStop = 0.0;

    if (ExistingStopOrder1.BuySell == BSE_SELL) {
      NewStop = PositionData.AveragePrice + (double)BE1OffsetTicks.GetInt() * sc.TickSize;
    }

    s_SCNewOrder ModifyStopOrder1;
    ModifyStopOrder1.InternalOrderID = Stop1OrderID;
    ModifyStopOrder1.Price1 = NewStop;

    if (sc.ModifyOrder(ModifyStopOrder1) != SCTRADING_ORDER_ERROR) {
      logMessage.Format("SL 1 order moved to BE");
      if (LogMessages.GetYesNo() == 1) sc.AddMessageToLog(logMessage, 1);
    }
    else {
      logMessage.Format("Error modifying SL 1 order, ID: %u", Stop1OrderID);
      if (LogMessages.GetYesNo() == 1) sc.AddMessageToLog(logMessage, 1);
    }
  }
  moveBE1triggered = 1;
}

Thanks for your great support!
Date Time Of Last Edit: 2019-09-03 06:27:42
imagelive-trade.png / V - Attached On 2019-09-03 06:16:44 UTC - Size: 141.33 KB - 234 views
imagesim-trade.png / V - Attached On 2019-09-03 06:16:48 UTC - Size: 158.84 KB - 240 views
imageorders-live.png / V - Attached On 2019-09-03 06:22:32 UTC - Size: 139.44 KB - 256 views