Login Page - Create Account

Support Board


Date/Time: Mon, 10 Mar 2025 07:50:54 +0000



Post From: Sample code for sc.SetAttachedOrders

[2022-01-21 14:57:55]
1+1=10 - Posts: 270
Assuming you’re already in a position, then yes, you can cancel the original target/stop orders and use. (If the entry order is still active then note that this OCO Target/Stop pair will not be attached to the entry order.):


s_SCNewOrder NewOrder;
NewOrder.OrderType = SCT_ORDERTYPE_OCO_LIMIT_STOP

// Fill in other properties using instructions below. Then sc.BuyOrder(NewOrder);

Notes: Use s_NewOrder::Price1 to set the Limit price and s_NewOrder::Price2 to set the Stop price. Use sc.BuyOrder() or sc.SellOrder to submit the order when using this order type. All of the standard Auto Trade Management logic applies when using this order type, so you may want to use Unmanaged Automated Trading when submitting this type of order, so there are no restrictions.