Support Board
Date/Time: Sun, 24 Nov 2024 14:09:14 +0000
[Programming Help] - Order events?
View Count: 426
[2024-05-24 14:24:35] |
User504477 - Posts: 26 |
Are there any events to use in the study for getting information on order placed/removed/modified on the chart? TY!
|
[2024-05-24 14:27:18] |
Sierra_Chart Engineering - Posts: 17156 |
In the case of ACSIL, there is no direct notification of order of events like this. You have to get the details of an order, every time the study function is called and see if there are changes.
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, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2024-05-24 17:43:16] |
User504477 - Posts: 26 |
Could you give me some pointers as to which function(s) should I call to get the changes? I tried GetTradePosition and GetTradeListSize/GetTradeListEntry and didn't help. May be I'm using them incorrectly...
|
[2024-05-25 00:35:27] |
ForgivingComputers.com - Posts: 960 |
Automated Trading From an Advanced Custom Study: s_SCTradeOrder Structure Members Look for OrderStatusCode. Date Time Of Last Edit: 2024-05-25 00:36:32
|
[2024-05-25 01:10:00] |
User504477 - Posts: 26 |
Looks like it is for placing an order from a study? I'm looking for a way to get details new order placed via chart/keyboard short cut etc..
|
[2024-05-25 10:55:43] |
JohnR - User831573 - Posts: 306 |
I have not used this, but I found this in the docs. ... checking the s_SCTradeOrder::OrderStatusCode for them by getting the trade order data with the sc.GetOrderByOrderID function and make sure they are no longer working by using the IsWorkingOrderStatus function. Hope this helps. Johnr |
[2024-05-25 17:05:29] |
ForgivingComputers.com - Posts: 960 |
Looks like it is for placing an order from a study? I'm looking for a way to get details new order placed via chart/keyboard short cut etc..
You place orders with the s_SCNewOrder structure. The s_SCTradeOrder is for orders that exist(ed). if (OrderID != 0)
{ s_SCTradeOrder TradeOrderData; int Result = sc.GetOrderByOrderID(NewOrder.InternalOrderID, TradeOrderData); if (Result != SCTRADING_ORDER_ERROR) { double FillPrice = TradeOrderData.AvgFillPrice; } int OrderStatusCode = TradeOrderData.OrderStatusCode; if (OrderStatusCode == SCT_OSC_FILLED) { // The order has completely filled } } |
[2024-05-26 03:12:03] |
User504477 - Posts: 26 |
How do I know the order ID for the order that was placed on a chart manually and not yet filled? Again, I don't want to place an order from the study. Instead, I'm trying to capture the new order placed via the chart or keyboard shortcut or via the DOM and modify it in the study... |
[2024-05-26 03:39:50] |
User504477 - Posts: 26 |
Never mind. I think I figured it out. TY! everyone
|
[2024-05-27 04:20:00] |
User504477 - Posts: 26 |
I implemented this logic to capture the just placed order from the chart. --- s_SCTradeOrder orderInfo; SCString text; int& index = sc.GetPersistentInt(1); while (sc.GetOrderByIndex(index, orderInfo) != SCTRADING_ORDER_ERROR) { ++index; orders[orderInfo.InternalOrderID][orderInfo.OrderStatusCode] = orderInfo; text.Format("%d, %d, %s, %f, %f, %s, %s, %d", orderInfo.InternalOrderID, orderInfo.ParentInternalOrderID, orderInfo.OrderType.GetChars(), orderInfo.OrderQuantity, orderInfo.FilledQuantity, orderTypes[orderInfo.BuySell].GetChars(), orderStatusMap[orderInfo.OrderStatusCode].GetChars(), orderInfo.IsSimulated); log2(sc, text); } I'm facing couple of issues. 1. In sim mode, it logs the following when I place a BUY LIMIT order. 1159, 0, Limit, 1.000000, 0.000000, SCT_ORDERTYPE_LIMIT, Open, 1 but in non-sim mode (realtime), logs nothing. 2. When I close(Cancel) the BUY LIMIT order, I get nothing in both modes. What am I missing? Date Time Of Last Edit: 2024-05-27 18:02:06
|
[2024-05-28 17:29:32] |
User504477 - Posts: 26 |
any pointers? TY!
|
[2024-05-28 17:48:30] |
ForgivingComputers.com - Posts: 960 |
Are you setting sc.SendOrdersToTradeService in the study? If you don't set it, the default is simulation. The easiest way to do this is to sync it to Simulation mode being off: sc.SendOrdersToTradeService = !sc.GlobalTradeSimulationIsOn;
|
[2024-05-28 17:56:14] |
User431178 - Posts: 541 |
any pointers? TY! 1. Do you have error messages in the trade service log? 2. Refer to this info about when orders are cleared from the list - Trading Information Windows: Automatic Clearing of Orders To determine if there is a change in order quantities (new, cancelled, or updated) you could query the position data, any of the items listed below could be useful. PositionQuantity NonAttachedWorkingOrdersExist AllWorkingBuyOrdersQuantity AllWorkingSellOrdersQuantity You would of course have to store each as a persistent variable so you know the state from the previous function call. Some of the members of s_SCPositionData are not documented, but you can inspect SCStructures.h to see what information is available. Date Time Of Last Edit: 2024-05-28 17:56:45
|
[2024-05-28 18:16:14] |
User504477 - Posts: 26 |
TY! With the 1st change from @bradh, I see the code logs whenever I place an order on the chart in realtime mode. But no indication if the order has been filled or cancelled. I guess I'll need additional logic to see if the order has been cancelled or filled. I see no error messages. |
To post a message in this thread, you need to log in with your Sierra Chart account: