Login Page - Create Account

Support Board


Date/Time: Tue, 23 Apr 2024 20:14:30 +0000



SCT_ORDERTYPE_OCO_BUY_STOP_SELL_STOP question

View Count: 1714

[2014-04-10 04:32:03]
onnb - Posts: 660
When submitting orders of the type, how do I set the stop and target for each of the entry orders?

As an example, say I want to place a Buy Stop at 100 and a sell stop at 50.
I want to define for the Buy stop an OCO with target 110 and stop at 90.
I want to definefor the sell stop an OCO with target 40 and stop at 60.

Is it possible to do this?
[2014-04-10 23:22:38]
Sierra Chart Engineering - Posts: 104368
Here you go:
  s_SCNewOrder NewOrder;
  NewOrder.OrderQuantity = 4;
  NewOrder.OrderType = SCT_ORDERTYPE_OCO_BUY_STOP_SELL_STOP;

  NewOrder.Price1 = Last + 10 * sc.TickSize;
  NewOrder.Price2 = Last - 10 * sc.TickSize;

  // Optional: Add target and stop Attached Orders to each stop in the OCO pair.
  NewOrder.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT;
  NewOrder.Target1Offset = 4 * sc.TickSize;
  NewOrder.AttachedOrderStop1Type = SCT_ORDERTYPE_STOP;
  NewOrder.Stop1Offset = 4 * sc.TickSize;

  if ( sc.SubmitOCOOrder(NewOrder) >0)
  {

    int BuyStopOrder1ID = NewOrder.InternalOrderID;
    int SellStopOrder2ID = NewOrder.InternalOrderID2;

  }

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2014-04-10 23:29:19]
onnb - Posts: 660
I fear that my example was ok but not the best. I need to set the Target/Stop prices for each entry OCO as a price value (not an offset). Can I do that prior to calling SubmitOCOOrder or do I need to modify the exit OCO's after calling SubmitOCOOrder?
[2014-04-11 00:40:03]
Sierra Chart Engineering - Posts: 104368
You can set the Target and Stop as price values. For example, for the target you would use the Target1Price member.

However , these will be converted back to offsets internally which means that you might have to modify the orders after they become "Open" to make sure they are at the prices that you want.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2014-04-11 03:28:57]
onnb - Posts: 660
You can set the Target and Stop as price values. For example, for the target you would use the Target1Price member.

I would need to have Target1Price for the Sell order and Target1Price for the buy order which I don't think is available in the api - just want to confirm I am not missing anything?

Looking at the api, I see that I would need to do something like this where I set the target1/stop1 fields after calling SubmitOCOOrder:

s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = 4;
NewOrder.OrderType = SCT_ORDERTYPE_OCO_BUY_STOP_SELL_STOP;

NewOrder.Price1 = Last + 10 * sc.TickSize;
NewOrder.Price2 = Last - 10 * sc.TickSize;

// Optional: Add target and stop Attached Orders to each stop in the OCO pair.
NewOrder.AttachedOrderTarget1Type = SCT_ORDERTYPE_LIMIT;
NewOrder.Target1Offset = 4 * sc.TickSize;
NewOrder.AttachedOrderStop1Type = SCT_ORDERTYPE_STOP;
NewOrder.Stop1Offset = 4 * sc.TickSize;

if ( sc.SubmitOCOOrder(NewOrder) >0)
{

int BuyStopOrderID = NewOrder.InternalOrderID;
int SellStopOrderID = NewOrder.InternalOrderID2;

// modify the target and stop of both the orders
s_SCNewOrder order;
order.InternalOrderID = BuyStopOrderID;
order.Target1Price = 110;
order.Stop1Price = 90;
sc.ModifyOrder(order);

order.InternalOrderID = SellStopOrderID;
order.Target1Price = 40;
order.Stop1Price = 60;
sc.ModifyOrder(order);

}


I'm first trying to verify that I need to modify the target/stop of each OCO like this or not. I have a follow up question based on the answer to this.
[2014-04-11 04:12:03]
Sierra Chart Engineering - Posts: 104368
// modify the target and stop of both the orders
s_SCNewOrder order;
order.InternalOrderID = BuyStopOrderID;
order.Target1Price = 110;
order.Stop1Price = 90;
sc.ModifyOrder(order);

order.InternalOrderID = SellStopOrderID;
order.Target1Price = 40;
order.Stop1Price = 60;
sc.ModifyOrder(order);

This will not work. As the documentation says here:
https://www.sierrachart.com/index.php?l=doc/doc_ACSILTrading.html#s_SCNewOrder

When you are modifying the Stop or Target order you will use Price1. Also when submitting the OCO order you do not have access to the internal order IDs for the second Target and Stop order set. You will have to search for those by iterating through the orders, but we can add the capability to set them.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2014-04-11 04:23:28
[2014-04-11 04:32:18]
onnb - Posts: 660
Yes, I see the issue. I can only modify Price and quantity and I'd have to iterate.

but we can add the capability to set them.
If by that you mean that I would be able to set the second Target/Stop order set before calling SubmitOCO that would be great. How can I follow when this will be ready?
[2014-07-28 18:43:17]
ejtrader - Posts: 688
SC Team - Following up on this - if this was implemented at some point.

Thanks
[2014-07-29 07:23:25]
sampater - Posts: 243
but we can add the capability to set them.
+ 1
[2014-07-29 09:34:32]
Sierra Chart Engineering - Posts: 104368
Everything discussed in this thread has either existed or has been added.

What we said previously about not being able to get the internal order IDs for the Attached Orders for the second order in an OCO top-level parent order, was not correct. You can:
https://www.sierrachart.com/index.php?l=doc/doc_ACSILTrading.html#TargetInternalOrderID
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2014-07-29 09:34:40

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

Login

Login Page - Create Account