Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 08:51:50 +0000



[Programming Help] - How to submit Trail stop and a limit OCO with ACSIL

View Count: 246

[2024-06-16 21:02:22]
User806682 - Posts: 14
I'm building a trading system with ACSIL and at one point once the system is in a position, I want to submit an OCO that has a trailing stop and a target limit order.
I haven't been able to figure out to do this, and I've tried a few different configurations from the different forum posts I've read.

For example, if the system is already LONG 1 contract. Here are two order types I've tried without success:


// This order just flattens position because I think it doesn't have an OrderQuantity and it seems to default to a market order
s_SCNewOrder NewOrder;
NewOrder.OCOGroup1Quantity = 1;
NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
NewOrder.Target1Price = xxx; // This is a higher value than where the market is trading
NewOrder.AttachedOrderStop1Type = SCT_ORDERTYPE_TRAILING_STOP;
NewOrder.Stop1Offset = xxx; // This is a lower value than where the market is trading
sc.SellOrder(NewOrder);


// This order successfully submits the trailing stop but there is no target
s_SCNewOrder NewOrder;
NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
NewOrder.OrderType = SCT_ORDERTYPE_TRAILING_STOP;
NewOrder.OrderQuantity = 1;
NewOrder.Price1 = xxx; // This is a lower value than where the market is trading
NewOrder.Price2 = xxx; // This is a higher value than where the market is trading (expecting this to be the target)
sc.SellOrder(NewOrder);


Lastly, I noticed that it is possible to send this type of attached order manually using the trade window. I just need help on how to do this with ACSIL.
Thank you.
[2024-06-19 01:19:36]
ForgivingComputers.com - Posts: 960

// You are using two different ways to specify targets and stops. The Target and Stop offsets will be used to calculate the actual price of the order

s_SCNewOrder NewOrder;
NewOrder.OCOGroup1Quantity = 1;
NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
NewOrder.Target1Offset = xxx; // This a positive number of points. You don't need to worry about above or below market
NewOrder.AttachedOrderStop1Type = SCT_ORDERTYPE_TRAILING_STOP;
NewOrder.Stop1Offset = xxx; // This a positive number of points. You don't need to worry about above or below market
sc.SellOrder(NewOrder);

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account