Support Board
Date/Time: Sun, 01 Jun 2025 01:35:11 +0000
[Programming Help] - ACSIL - Unable to send concurrent Buy and Sell Orders
View Count: 177
[2025-05-02 15:57:52] |
NeilPatel84 - Posts: 1 |
Hi, When trading from the chart directly I can send Buy Limit and Sell Limit orders on the same SIM account and same Symbol and have them both be open without issue. I'm trying to program through ACSIL to do the same. Following the documentation I've set these variables: sc.AllowOnlyOneTradePerBar = FALSE; sc.MaximumPositionAllowed = 10; sc.AllowMultipleEntriesInSameDirection = TRUE; sc.AllowOppositeEntryWithOpposingPositionOrOrders = TRUE; sc.SupportReversals = TRUE; sc.AllowEntryWithWorkingOrders = TRUE; sc.CancelAllOrdersOnEntriesAndReversals = FALSE; sc.CancelAllWorkingOrdersOnExit = FALSE; I'm trying to implement the buy and sell like this with triggered trailing stops float buyPrice = sc.Ask; float sellPrice = sc.Bid; s_SCNewOrder buyOrder; buyOrder.OrderType = SCT_ORDERTYPE_LIMIT; buyOrder.OrderQuantity = 1; buyOrder.TextTag = "TwoWayBuy"; buyOrder.Price1 = buyPrice - (limit * tickSize); buyOrder.AttachedOrderStop1Type = SCT_ORDERTYPE_TRIGGERED_TRAILING_STOP_3_OFFSETS; buyOrder.Stop1Offset = stopTicks * tickSize; buyOrder.TriggeredTrailStopTriggerPriceOffset = trailingStopTriggerTicks * tickSize; buyOrder.TriggeredTrailStopTrailPriceOffset = trailingStopTicks * tickSize; s_SCNewOrder sellOrder; sellOrder.OrderType = SCT_ORDERTYPE_LIMIT; sellOrder.OrderQuantity = 1; sellOrder.TextTag = "TwoWaySell"; sellOrder.Price1 = sellPrice + (limit * tickSize); sellOrder.AttachedOrderStop1Type = SCT_ORDERTYPE_TRIGGERED_TRAILING_STOP_3_OFFSETS; sellOrder.Stop1Offset = stopTicks * tickSize; sellOrder.TriggeredTrailStopTriggerPriceOffset = trailingStopTriggerTicks * tickSize; sellOrder.TriggeredTrailStopTrailPriceOffset = trailingStopTicks * tickSize; LongOrderID = sc.BuyEntry(buyOrder); if (LongOrderID < 0) { SCString errorMsg; errorMsg.Format("Long order failed with error code: %d", LongOrderID); sc.AddMessageToLog(errorMsg, 1); } else { SCString successMsg; successMsg.Format("Long order sent successfully with ID: %d at price: %.2f", LongOrderID, buyPrice - (limit * tickSize)); sc.AddMessageToLog(successMsg, 0); } ShortOrderID = sc.SellEntry(sellOrder); if (ShortOrderID < 0) { SCString errorMsg; errorMsg.Format("Short order failed with error code: %d", ShortOrderID); sc.AddMessageToLog(errorMsg, 1); } else { SCString successMsg; successMsg.Format("Short order sent successfully with ID: %d at price: %.2f", ShortOrderID, sellPrice + (limit * tickSize)); sc.AddMessageToLog(successMsg, 0); } The error I get in the Trade Service log is 2025-05-02 11:48:56.320 | Auto-trade: MESM25-CME[M] 1 Min #3 | RSI Trend Bracket Order | SellEntry | Bar start date-time: 2025-05-02 11:38:00.000 | SellEntry signal is ignored because working orders exist. My Trade order window show an open and unfilled order Entry Time Last Activity Time Symbol Status Internal Order ID Order Type Buy/Sell Open/Close Order Quantity Price Price 2 Filled Quantity Average Fill Price Parent Internal Order ID Time in Force Good Till DateTime Service Order ID Trade Account Link ID OCO ID LastOrderActionSource Client Order ID Exchange Order ID Text Tag TrailOrderOffset TrailOrderStepAmount 2025-05-02 11:38:44.849 2025-05-02 11:38:44.849 [Sim]MESM25-CME Open 15233 Limit Buy Open 1 5695.25 0.00 0 0.00 0 Day 15233 Sim1 15233 0 Simulated order accepted TwoWayBuy 0.00 0.00 2025-05-02 11:38:44.849 2025-05-02 11:38:44.849 [Sim]MESM25-CME Pending Child-Client 15234 Triggered Trail Stop Sell Close 0 5692.75 0.00 0 0.00 15233 Day Sim1 0 15234 Auto-trade: MESM25-CME[M] 1 Min #3 | RSI Trend Bracket Order | BuyEntry | TwoWayBuy | Bar start date-time: 2025-05-02 11:38:00.000 | Last: 5695.75 | AOE=true | AOU=true. Attached Order TwoWayBuy 0.25 0.00 As I understand the same sim account and the same symbol can't have two open positions in opposite directions but these are intended to be unfilled orders (I have not added the code to cancel the opposing unfilled order once one order is filled). Again this works with manual entry. Entry Time Last Activity Time Symbol Status Internal Order ID Order Type Buy/Sell Open/Close Order Quantity Price Price 2 Filled Quantity Average Fill Price Parent Internal Order ID Time in Force Good Till DateTime Service Order ID Trade Account Link ID OCO ID LastOrderActionSource Client Order ID Exchange Order ID Text Tag TrailOrderOffset TrailOrderStepAmount 2025-05-02 11:44:02.042 2025-05-02 11:44:02.042 [Sim]MESM25-CME Open 15238 Limit Sell Open 1 5701.25 0.00 0 0.00 0 Day 15238 Sim1 15238 0 Simulated order accepted 0.00 0.00 2025-05-02 11:44:02.042 2025-05-02 11:44:02.042 [Sim]MESM25-CME Pending Child-Client 15239 Limit Buy Close 0 5700.25 0.00 0 0.00 15238 Good till Canceled Sim1 0 15239 MESM25-CME[M] 1 Min #3 | User order entry | Last: 5699.5 | AOE=true | AOU=true. Attached Order | Client side OCO order 0.00 0.00 2025-05-02 11:44:02.042 2025-05-02 11:44:02.042 [Sim]MESM25-CME Pending Child-Client 15240 Stop Buy Close 0 5706.25 0.00 0 0.00 15238 Good till Canceled Sim1 15240 15239 MESM25-CME[M] 1 Min #3 | User order entry | Last: 5699.5 | AOE=true | AOU=true. Attached Order | Client side OCO order 0.00 0.00 2025-05-02 11:43:59.159 2025-05-02 11:43:59.159 [Sim]MESM25-CME Open 15235 Limit Buy Open 1 5697.75 0.00 0 0.00 0 Day 15235 Sim1 15235 0 Simulated order accepted 0.00 0.00 2025-05-02 11:43:59.159 2025-05-02 11:43:59.159 [Sim]MESM25-CME Pending Child-Client 15236 Limit Sell Close 0 5698.75 0.00 0 0.00 15235 Good till Canceled Sim1 0 15236 MESM25-CME[M] 1 Min #3 | User order entry | Last: 5699 | AOE=true | AOU=true. Attached Order | Client side OCO order 0.00 0.00 2025-05-02 11:43:59.159 2025-05-02 11:43:59.159 [Sim]MESM25-CME Pending Child-Client 15237 Stop Sell Close 0 5692.75 0.00 0 0.00 15235 Good till Canceled Sim1 15237 15236 MESM25-CME[M] 1 Min #3 | User order entry | Last: 5699 | AOE=true | AOU=true. Attached Order | Client side OCO order 0.00 0.00 |
[2025-05-04 02:11:56] |
ForgivingComputers.com - Posts: 1060 |
Try this: s_SCNewOrder NewOrder;
NewOrder.OrderType = SCT_ORDERTYPE_OCO_BUY_LIMIT_SELL_LIMIT; NewOrder.Price1 = sc.Bid - (limit * tickSize); // Buy Price NewOrder.Price2 = sc.Ask + (limit * tickSize); // Sell Price NewOrder.OrderQuantity = 1; // stops, targets, etc. int Result = sc.SubmitOCOOrder(NewOrder); Date Time Of Last Edit: 2025-05-04 02:13:37
|
To post a message in this thread, you need to log in with your Sierra Chart account: