Support Board
Date/Time: Mon, 25 Nov 2024 06:45:24 +0000
[Programming Help] - Sending Orders for Multiple Symbols
View Count: 301
[2024-03-18 22:34:58] |
Gradient - Posts: 89 |
Hi, I've implemented logic to submit orders for multiple symbols from a single chart. I'm reading in the BaseData of the reference chart and storing the last price in a subgraph array (See Below) // Define a graph data object to get all of the base graph data SCGraphData BaseGraphData; // Get the base graph data from the specified chart sc.GetChartBaseData(ChartNumber.GetInt(), BaseGraphData); // Define a reference to the High array SCFloatArrayRef LastArray = BaseGraphData[SC_LAST]; // Array is empty. Nothing to do. if(LastArray.GetArraySize() == 0){ return; } // Get the index in the specified chart that is // nearest to current index. int RefChartIndex = sc.GetNearestMatchForDateTimeIndex(ChartNumber.GetInt(), sc.Index); double NearestRefChartLast = LastArray[RefChartIndex]; //store other symbol price sc.Subgraph[5][sc.Index]=NearestRefChartLast; The data from the reference chart is being read into the current chart, however, I've noticed multiple bugs with submitting orders. When attempting to submit orders on a minute based intraday chart, orders are being executed for one symbol (the base symbol). No orders are appearing for the other symbol. When I check the working orders I can see orders submitted for the second symbol but I also see a growing list of submissions. The second symbol will have new order submissions every second or so but no positions. Also there are no fills or positions in the chart of the second symbol. I also noticed that for the base symbol (i.e. the chart that contains the study), even though I'm simply submitting a limit order, it continuously places OCO orders. Below is an example of the order submission: //symbol 1 Symbol1ParentOrder.OrderQuantity=1; Symbol1ParentOrder.OrderType=SCT_ORDERTYPE_LIMIT; Symbol1ParentOrder.TimeInForce=SCT_TIF_IMMEDIATE_OR_CANCEL; //Symbol1ParentOrder.MaximumChaseAsPrice=1.0/2; Symbol1ParentOrder.Price1=sc.Close[sc.Index]; //symbol 2 Symbol2ParentOrder.Symbol=symbol; Symbol2ParentOrder.OrderQuantity=1; Symbol2ParentOrder.OrderType=SCT_ORDERTYPE_LIMIT; Symbol2ParentOrder.TimeInForce=SCT_TIF_IMMEDIATE_OR_CANCEL; //Symbol2ParentOrder.MaximumChaseAsPrice=1.0/2; //get price of other symbol from subgraph array Symbol2ParentOrder.Price1=sc.Subgraph[5][sc.Index]; //send order int response=static_cast<int>(sc.BuyEntry(Symbol1ParentOrder)); int sym2Response=static_cast<int>(sc.BuyOrder(Symbol2ParentOrder)); I've attached an example of the OCO order being sent on the base symbol chart even though I'm not submitting an OCO order. Can someone advise how to resolve these issues? Thanks. Date Time Of Last Edit: 2024-03-18 22:45:40
|
OCO Error 1.png / V - Attached On 2024-03-18 22:44:29 UTC - Size: 14.31 KB - 73 views |
[2024-03-18 23:32:23] |
Gradient - Posts: 89 |
I've tested changing the order type to MARKET and I'm still experiencing the same behavior. Even though I'm submitting Market orders, OCOs are still being executed somehow, albeit only for the base symbol. The second symbol is continuing to accumulate orders in the working orders queue but nothing is being executed. Essentially, a single order for the second symbol is being submitted, the queue is exponentially increasing at the same price as if the same order is being submitted several times, stating they are filled, but there are no executions for the second symbol. I've attached a view of the Trade Orders Window, displaying the behavior of the second symbol. |
Trade Orders Error.png / V - Attached On 2024-03-18 23:30:49 UTC - Size: 131.51 KB - 48 views |
[2024-03-19 02:42:09] |
Gradient - Posts: 89 |
NOTE: I removed the second symbol to check whether the error was due to submitting multiple orders. I experienced the same issue when submitting order for only one symbol. Even though I am submitting Market orders as displayed above, OCO orders are still being executed.
|
[2024-03-21 12:16:46] |
Gradient - Posts: 89 |
Hi, Can someone provide an update? |
[2024-03-21 12:30:39] |
User907968 - Posts: 823 |
Automated Trading From an Advanced Custom Study Automated Trading From an Advanced Custom Study: Submitting and Managing Orders for Different Symbol and/or Trade Account For OCO question, check: ACSIL Interface Members - Variables and Arrays: sc.UseGUIAttachedOrderSetting ACSIL Interface Members - Variables and Arrays: sc.SupportAttachedOrdersForTrading but there are no executions for the second symbol.
How do you arrive at that conclusion?
Date Time Of Last Edit: 2024-03-21 12:30:50
|
To post a message in this thread, you need to log in with your Sierra Chart account: