Support Board
Date/Time: Wed, 04 Feb 2026 05:18:17 +0000
[Programming Help] - ACSIL: Modifying Target 2 to Breakeven when Stop 1 fills (Split Parent / Independent OCO Issue)
View Count: 23
| [2026-02-03 21:35:03] |
| User214239 - Posts: 40 |
|
I am writing a custom ACSIL study to manage an automated strategy. I am stuck on a specific logic problem involving multi-target bracket management. The Goal: I place a trade with Quantity 2, using 2 Targets and 2 Stops. Example: Target 1: 20 ticks Target 2: 40 ticks Stop 1: 20 ticks Stop 2: 40 ticks Logic: When Stop 1 is hit (partial stop-out), I want the script to immediately move Target 2 to Breakeven (Entry Price). The Problem: My TradeActivityLog shows that Sierra Chart splits this order into two completely independent Parent Orders (what I call "Split Parents"). Group A: Parent ID 100 -> Linked to Target 1 & Stop 1. Group B: Parent ID 105 -> Linked to Target 2 & Stop 2. When Stop 1 (Group A) is filled, my ACSIL script receives the event. However, it cannot find Target 2 because Target 2 belongs to "Parent 105", which is not linked to the filled order. They seem to be invisible to each other in the database structure. What I have tried (and why it failed): Standard Attached Order ID Loop: I used sc.GetAttachedOrderIDs() on the filled order. Result: It only returns the orders for Group A (the Cancelled Target 1). It does not return Group B's orders. Tag-Based Scanning ("Autotrade Native"): I tagged the entry order with a specific text tag, hoping it would propagate. I scanned sc.GetOrderByIndex for any order with this tag. Result: The auto-generated child orders (Stops/Targets) often have OrderActionSource: Auto-sent child... and do not consistently inherit the custom Text Tag from the parent entry, making them unsearchable by tag. Trade Log Parsing (sc.GetOrderFillEntry): I monitored the fill log to detect a "Loss" fill (Price vs Entry). Result: While I can detect the loss, I still lack a reliable handle to the "Orphaned" Target 2 to modify it. Scanning all open orders for the symbol seems inefficient and risky if multiple strategies are running. Position State Monitoring: I monitored sc.GetTradePosition(Pos). If Pos.PositionQuantity drops (e.g., 2 to 1) and LastFillPrice indicates a loss, I trigger a modification. Result: This is hit-or-miss depending on when the Position update fires relative to the order cancellation. My Question: Is there a native ACSIL function or established pattern to link OCO Group A and OCO Group B? How do I reliably get the InternalOrderID of "Target 2" when the event triggering the logic is the fill of "Stop 1" (which has a different ParentID)? I am looking for the correct way to bridge this gap so I can modify the remaining target. If anyone has any experience solving this issued I'd really appreciate any help. Thank you. Date Time Of Last Edit: 2026-02-03 21:35:41
|
To post a message in this thread, you need to log in with your Sierra Chart account:
