Support Board
Date/Time: Mon, 23 Dec 2024 19:10:39 +0000
s_SCTradeOrder order lifetime
View Count: 1700
[2015-09-24 15:02:38] |
User35525 - Posts: 181 |
Revised: Please close this. I wanted to know if I could quickly query only active brackets. Even if there was a way, I'd still have to troubleshoot potential bracket problems (steps #1-3 below). ... Is there a function to grab just active orders (working and open), which I see at Trade >> Trade Orders and Positions? I'm using server-side brackets at CTS with SC 1296, and see all orders when I walk the order list with GetOrderByIndex. Just because a child is either SCT_OSC_FILLED or SCT_OSC_CANCELED doesn't tell me the OCO bracket is closed, as the parent or other child could be active. Is this normal, and if 'yes', is there a way I can walk the orders and only receive active/working/open orders, and not closed orders too? Some background: I'm walking the orders to get trade state of my OCO bracket, but think it would be easier if I only had to deal with active orders (at least it would eliminate step #4 below): 1) walk it once to get a complete list of parents, some being closed orders. 2) walk it again to get a complete list of children, some being closed orders. I believe it's theoretically possible to have children without parents (orphans), if orders are cancelled manually or anomalously at CTS, instead of within SC. 3) match-up parents and children, if possible. It's also possible to have naked brackets, meaning parents without attached stop (SL) orders. 4) now, to know if the order is active, you have to keep track of both the order "type" and "status" of both children; that is, if child1 cancels and child2 fills, that's a normal OCO exit; if child1 fills and child2 cancels, that's also a normal OCO exit; and if the parent type is changed to a market order and both children are cancelled, that's also normal, if you're flattening before a child gets filled. Thanks. Date Time Of Last Edit: 2015-09-25 03:58:11
|
[2015-09-27 09:07:34] |
Sierra Chart Engineering - Posts: 104368 |
Letting you know the response is still pending. We need to put together some code examples for this.
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 |
[2015-09-27 18:16:53] |
Sierra Chart Engineering - Posts: 104368 |
Here is a code example. One of the function calls in this code requires version 1300 which has not yet been released. SCSFExport scsf_TradingExampleIteratingOrderList(SCStudyInterfaceRef sc)
{ if (sc.SetDefaults) { // Set the study configuration and defaults. sc.GraphName = "Trading Example: Iterating Order List"; // This is false by default. sc.SendOrdersToTradeService = false; sc.AutoLoop = 0; sc.GraphRegion = 0; sc.FreeDLL = 0; return; } // This only serves as a code example and we do not want this code to run. return; // This is an example of iterating the order list in Sierra Chart for orders // matching the Symbol and Trade Account of the chart, and finding the orders // that have a working Order Status and are not Attached Orders. //The iteration must always be from zero until SCTRADING_ORDER_ERROR is returned. Do not reverse iterate because that is highly inefficient. sc.GetOrderByIndex is less efficient than using sc.GetOrderByOrderID. So it should not be called frequently. int Index = 0; s_SCTradeOrder OrderDetails; while( sc.GetOrderByIndex(Index, OrderDetails) != SCTRADING_ORDER_ERROR) { ++Index; // Increment the index for the next call to sc.GetOrderByIndex if (!IsWorkingOrderStatus(OrderDetails.OrderStatusCode)) continue; if (OrderDetails.ParentInternalOrderID != 0)//This means this is an Attached Order continue; //Get the internal order ID int InternalOrderID = OrderDetails.InternalOrderID; } int TargetInternalOrderID = -1; int StopInternalOrderID = -1; //This needs to be set to the parent internal order ID search for. Since we do not know what that is in this code example, it is set to zero here. int ParentInternalOrderID = 0; sc.GetAttachedOrderIDsForParentOrder(ParentInternalOrderID, TargetInternalOrderID, StopInternalOrderID); } 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: 2015-09-27 18:17:46
|
[2015-10-02 17:31:25] |
User35525 - Posts: 181 |
I am seeing a CPU exception when calling GetAttachedOrderIDsForParentOrder() with sc 1300, 1301, and 1302. Also, I was getting various compiler errors with IsWorkingOrderStatus() and sc.IsWorkingOrderStatus(), but saw IsWorking() in scstructures.h. Can I use that like this, which compiles okay? if (!OrderDetails.IsWorking()) continue; |
[2015-10-02 17:52:52] |
Sierra Chart Engineering - Posts: 104368 |
The exception will be fixed for sc.GetAttachedOrderIDsForParentOrder() in the next release. We are not getting any compiler errors for IsWorkingOrderStatus() . What are they? 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 |
[2015-10-02 19:42:23] |
User35525 - Posts: 181 |
Thanks about sc.GetAttachedOrderIDsForParentOrder(). For IsWorkingOrderStatus(), it was my error since this compiles: if (!IsWorkingOrderStatus(OrderDetails.OrderStatusCode)) continue;
But not this: int sid= OrderDetails.OrderStatusCode; if (!IsWorkingOrderStatus(sid)) continue; This was the compiler error: error: invalid conversion from 'int' to 'SCOrderStatusCodeEnum' [-fpermissive] if (!IsWorkingOrderStatus(sid)) continue; However this compiles: int sid= OrderDetails.OrderStatusCode; if (sid == SCT_OSC_FILLED){ //stopped-out. ... I think sc would need to provide "int StatusCodeTypeAsInt;" and "StatusCodeTypeAsInt(0)" within scstructures.h, and "bool IsWorkingOrderStatus(int OrderStatusCode)" within scconstants.h, for my example to be worksable. I don't need it, but see that it might be useful to somebody later. Then this would work: int sid= OrderDetails.StatusCodeTypeAsInt; if (!IsWorkingOrderStatus(sid)) continue; Date Time Of Last Edit: 2015-10-02 19:50:45
|
[2015-10-03 00:57:27] |
Sierra Chart Engineering - Posts: 104368 |
When you want to take a copy of the Order Status Code define it as this type: SCOrderStatusCodeEnum. This is all you need to do. 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 |
[2015-10-05 17:19:01] |
User35525 - Posts: 181 |
I'm getting a CPU exception for sc.GetAttachedOrderIDsForParentOrder() with 1304. This function will be really great, as it will let me make a single pass through the s_SCTradeOrder structure.
|
[2015-10-05 18:06:40] |
Sierra Chart Engineering - Posts: 104368 |
We do not encounter any exception when using sc.GetAttachedOrderIDsForParentOrder() in version 1304. We can see no reason for this at all. Confirm you are actually running 1304. 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 |
[2015-10-05 19:38:40] |
User35525 - Posts: 181 |
I'm sure it's version 1304. GetAttachedOrderIDsForParentOrder() seems to work, since TargetInternalOrderID and StopInternalOrderID get set correctly, but it causes the following CPU exception: CTS FIX: Received 'Account Update/Balance Data' collateral report. | 2015-10-05 14:20:48 CTS FIX: Received 'Account Update/Balance Data' collateral report. | 2015-10-05 14:20:48 Warning: The Custom DLL study "code_for_sc_engineering.scsf_tScreenStats" has just caused a CPU exception. | 2015-10-05 14:20:48 * Warning: This Custom DLL study may cause Sierra Chart to be unstable until you remove the study from your chart and restart Sierra Chart. | 2015-10-05 14:20:48 * If anybody wants to test my code, please see attached; simply put "set Fill Space" and "tScreenStats" on an empty chart and then submit a buy or sell server-side bracket OCO order. tScreenStats displays on the screen your order quantity, parent fill price, take profit, and stop loss. If GetAttachedOrderIDsForParentOrder() is commented, then there's no CPU exception, but nothing gets printed on the screen since it doesn't know the the OCO's children order ID's. Date Time Of Last Edit: 2015-10-05 19:51:36
|
code_for_sc_engineering.cpp - Attached On 2015-10-05 19:38:35 UTC - Size: 8.92 KB - 455 views |
[2015-10-06 01:17:55] |
Sierra Chart Engineering - Posts: 104368 |
Check your own code. The exception is occurring during a call to this: Buffer.Format("gLogger: gLogCntr=%d; pid=%d; oid=%d; tid= %d; sid=%d; ds=%d; ts=%d; msg=%s",
gLogCntr, oid, tid, sid, gLogged[gLogCntr][3], gLogged[gLogCntr][4], str.GetChars()); If GetAttachedOrderIDsForParentOrder() is commented, then there's no CPU exception 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: 2015-10-06 01:18:25
|
[2015-10-06 21:52:40] |
User35525 - Posts: 181 |
You guys are the best. GetAttachedOrderIDsForParentOrder() works perfectly and I have lots to learn about programming. I don't know another charting package this powerful with an easy-enough API for beginning programmers. Everything else is either engineered poorly, or difficult to program for traders, or both. You extended the API to help me, even though I had asked for the thread to be closed so you could get back to work doing more important support; and then you went beyond that and helped me with my programming issue. Thank you! I'm a customer for life and hope to return the favor by helping others in the forum over the years. |
[2015-10-08 02:29:52] |
Sierra Chart Engineering - Posts: 104368 |
Thank you for the comment.
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 |
To post a message in this thread, you need to log in with your Sierra Chart account: