Support Board
Date/Time: Tue, 26 Aug 2025 08:51:18 +0000
[Programming Help] - ACSIL - Unable to send concurrent Buy and Sell Orders
View Count: 581
[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: 1105 |
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
|
[2025-07-28 17:56:04] |
stockwet - Posts: 37 |
I'm running into the same issue. I have the following trade configuration ... sc.AllowOppositeEntryWithOpposingPositionOrOrders = true; sc.CancelAllOrdersOnEntriesAndReversals = true; The OCO workaround seems okay, but, I need the orders to have their own attached orders when they trigger. Anyone have a solution for this one? |
[2025-07-28 18:08:28] |
User431178 - Posts: 763 |
Pretty sure this sc.CancelAllOrdersOnEntriesAndReversals = true;
should besc.CancelAllOrdersOnEntriesAndReversals = false;
otherwise you just cancel the order as soon as the opposite order is entered.
|
[2025-07-28 20:56:28] |
stockwet - Posts: 37 |
The documentation states the opposite, which is why both @NeilPatel84 and I have this configured to be true. I tested with false just for fun and it didn't work. Here's the relevant documentation. AllowOppositeEntryWithOpposingPositionOrOrders The default value for this variable is TRUE (Yes). When this variable is set to FALSE (No), then a Buy Entry or Sell Entry is not allowed if there is a Trade Position or working orders already existing in the opposite direction. Otherwise, the signal will be allowed. Complete details about how this variable works can be found in the BuyEntry and SellEntry Order Action sections. If this is set to TRUE (Yes), you should set CancelAllOrdersOnEntriesAndReversals to TRUE (Yes) when using Attached Orders so that those Attached Orders will be canceled since the current Trade Position will be reduced in quantity or reversed. This also wouldn't impact the issue cited in the message log since it's the entry order, not an attached order: SellEntry signal is ignored because working orders exist
|
[2025-07-28 21:34:38] |
User431178 - Posts: 763 |
Well I don't know anything about the rest of your code. Here are the exact settings I have in bots that send multiple buy and sell entries simultaneously, each with their own OCO stops/targets. sc.SendOrdersToTradeService = 0; sc.MaximumPositionAllowed = 100000; sc.SupportReversals = 0; sc.SupportAttachedOrdersForTrading = 0; sc.UseGUIAttachedOrderSetting = 0; sc.AllowMultipleEntriesInSameDirection = 1; sc.CancelAllOrdersOnEntriesAndReversals = 0; sc.CancelAllOrdersOnReversals = 1; sc.AllowOnlyOneTradePerBar = 0; sc.AllowOppositeEntryWithOpposingPositionOrOrders = 1; sc.AllowEntryWithWorkingOrders = 1; sc.CancelAllWorkingOrdersOnExit = 1; I should add, outside of the set defaults block sc.SendOrdersToTradeService and sc.MaximumPositionAllowed are set to appropriate values, and scale in/out is disabled. sc.SupportTradingScaleIn = 0; sc.SupportTradingScaleOut = 0; This also wouldn't impact the issue cited in the message log since it's the entry order, not an attached order: SellEntry signal is ignored because working orders exist Attached or unattached is nothing to do with it. When CancelAllOrdersOnEntriesAndReversals is set to TRUE (Yes), and there is a Buy Entry or a Sell Entry or a Reversal Order Action given, then all working orders except for market orders, for the Symbol and Trade Account of the chart that the trading system study is applied to will be canceled before the entry or reversal order is submitted. The entry or reversal order is submitted immediately after the orders are requested to be canceled. If the order or orders cannot be canceled and the order cancellation has been rejected by the Trading service, then this can result in a Trade Position Quantity which may exceed what was intended. This is something to consider. When CancelAllOrdersOnEntriesAndReversals is set to FALSE (No), then existing working orders for the Symbol and Trade Account will not be canceled. Suggest reading the documentation about unmanaged automated trading, because that is what you probably need to be doing. Automated Trading Management: Unmanaged Automated Trading Date Time Of Last Edit: 2025-07-29 08:04:48
|
To post a message in this thread, you need to log in with your Sierra Chart account: