Support Board
Date/Time: Sun, 22 Dec 2024 05:40:16 +0000
Can I modify using s_SCNewOrder ModifyOrder an order given by the spreadsheet?
View Count: 1534
[2015-03-02 17:11:45] |
CMG - Posts: 179 |
Can I modify an order given by the spreadsheet using s_SCNewOrder ModifyOrder? I have tried a lot of code but the result is always "Internal Order Id given to sc.ModifyOrder is 0". I am using a sc.GetOrderByIndex instruction to get the StopAllOrderID that I want to modify given a series of conditions. Any thoughts please.. PV |
[2015-03-02 18:35:33] |
Sierra Chart Engineering - Posts: 104368 |
Yes you can but you need to make sure that you are getting the correct internal order ID.
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-03-03 06:59:17] |
CMG - Posts: 179 |
Yes, that is the trick... since I am using the sc.GetOrderByIndex instruction it keeps looping after it changes the order because it finds open orders, have tried many ways to exit the loop however I was wondering if you have an example with LinkId which seems according to your documentation can solve this loop.. just in case the message on the service log is http://www.sierrachart.com/image.php?l=1425365861117.png [support women who code] PV |
[2015-03-03 07:04:29] |
Sierra Chart Engineering - Posts: 104368 |
When you are looking through the orders, what is the particular order you are looking for? How are you isolating it?
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-03-03 07:17:51] |
CMG - Posts: 179 |
After the sc.GetOrderByIndex, I look for open orders, that are attached orders, that are not filled, get the InternalOrderID and add 2, (all stops are the internal order id + 2) and then modify them. s_SCNewOrder ModifyOrder; ModifyOrder.InternalOrderID = OrderID+2; ModifyOrder.Price1 = FirstTradePrice; sc.ModifyOrder(ModifyOrder); |
[2015-03-04 04:09:56] |
CMG - Posts: 179 |
Hello, Any ideas on this one... I have not been able to fix it. PV |
[2015-03-05 00:18:22] |
Sierra Chart Engineering - Posts: 104368 |
We are going to write up an example show how to get working stop attached orders and modify 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 |
[2015-03-05 00:31:19] |
Sierra Chart Engineering - Posts: 104368 |
Here is an example: /*==========================================================================*/ SCSFExport scsf_TradingExampleModifyStopAttachedOrders(SCStudyInterfaceRef sc) { // Define references to the Subgraphs and Inputs for easy reference SCSubgraphRef BuyEntrySubgraph = sc.Subgraph[0]; SCSubgraphRef SellEntrySubgraph = sc.Subgraph[1]; SCSubgraphRef FastSimpMovAvgSubgraph = sc.Subgraph[4]; SCSubgraphRef SlowSimpMovAvgSubgraph = sc.Subgraph[5]; SCInputRef Enabled = sc.Input[0]; if (sc.SetDefaults) { // Set the study configuration and defaults. sc.GraphName = "Trading Example: Modify Stop Attached Orders"; BuyEntrySubgraph.Name = "Buy Entry"; BuyEntrySubgraph.DrawStyle = DRAWSTYLE_ARROWUP; BuyEntrySubgraph.PrimaryColor = RGB(0, 255, 0); BuyEntrySubgraph.LineWidth = 2; BuyEntrySubgraph.DrawZeros = false; SellEntrySubgraph.Name = "Sell Entry"; SellEntrySubgraph.DrawStyle = DRAWSTYLE_ARROWDOWN; SellEntrySubgraph.PrimaryColor = RGB(255, 0, 0); SellEntrySubgraph.LineWidth = 2; SellEntrySubgraph.DrawZeros = false; FastSimpMovAvgSubgraph.Name = "Fast Moving Average"; FastSimpMovAvgSubgraph.DrawStyle = DRAWSTYLE_LINE; FastSimpMovAvgSubgraph.PrimaryColor = RGB(255, 255, 255); FastSimpMovAvgSubgraph.DrawZeros = false; FastSimpMovAvgSubgraph.LineWidth = 2; SlowSimpMovAvgSubgraph.Name = "Slow Moving Average"; SlowSimpMovAvgSubgraph.DrawStyle = DRAWSTYLE_LINE; SlowSimpMovAvgSubgraph.PrimaryColor = RGB(0, 255, 0); SlowSimpMovAvgSubgraph.DrawZeros = false; SlowSimpMovAvgSubgraph.LineWidth = 2; Enabled.Name = "Enabled"; Enabled.SetYesNo(0); sc.AllowMultipleEntriesInSameDirection = false; sc.MaximumPositionAllowed = 2; sc.SupportReversals = false; // This is false by default. sc.SendOrdersToTradeService = false; sc.AllowOppositeEntryWithOpposingPositionOrOrders = false; sc.SupportAttachedOrdersForTrading = false; sc.CancelAllOrdersOnEntriesAndReversals= false; sc.AllowEntryWithWorkingOrders = false; sc.CancelAllWorkingOrdersOnExit = true; // Only 1 trade for each Order Action type is allowed per bar. sc.AllowOnlyOneTradePerBar = true; //This needs to be set to true when a trading study uses trading functions. sc.MaintainTradeStatisticsAndTradesData = true; sc.AutoLoop = 1; sc.GraphRegion = 0; sc.FreeDLL = 0; return; } if (!Enabled.GetYesNo()) return; int OrderIndex = 0; while (true) { // Get the next order details structure. s_SCTradeOrder OrderDetails; if (sc.GetOrderByIndex(OrderIndex, OrderDetails) == SCTRADING_ORDER_ERROR) break; ++OrderIndex; // Skip if not a working order. if (!OrderDetails.IsWorking()) continue; // Skip if not an attached order. if (!OrderDetails.IsAttachedOrder()) continue; // Skip if not a stop order. if (OrderDetails.OrderTypeAsInt != SCT_ORDERTYPE_STOP) continue; //Modify order s_SCNewOrder ModifyOrder; ModifyOrder.InternalOrderID = OrderDetails.InternalOrderID; //Modify order to same price. Since the price is the same, it will be ignored, but this only serves as an example of an order modification. ModifyOrder.Price1 = OrderDetails.Price1; sc.ModifyOrder(ModifyOrder); } } 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-03-05 18:00:21] |
CMG - Posts: 179 |
Hi thanks, but the problem persist: on the service log I keep getting the recurring message. I want to clarify that the modify order does what is suppose to do. http://www.sierrachart.com/image.php?l=1425578308155.png PV |
[2015-03-05 20:12:24] |
Sierra Chart Engineering - Posts: 104368 |
Use this updated example: /*==========================================================================*/
SCSFExport scsf_TradingExampleModifyStopAttachedOrders(SCStudyInterfaceRef sc) { // Define references to the Subgraphs and Inputs for easy reference SCSubgraphRef BuyEntrySubgraph = sc.Subgraph[0]; SCSubgraphRef SellEntrySubgraph = sc.Subgraph[1]; SCSubgraphRef FastSimpMovAvgSubgraph = sc.Subgraph[4]; SCSubgraphRef SlowSimpMovAvgSubgraph = sc.Subgraph[5]; SCInputRef Enabled = sc.Input[0]; if (sc.SetDefaults) { // Set the study configuration and defaults. sc.GraphName = "Trading Example: Modify Stop Attached Orders"; BuyEntrySubgraph.Name = "Buy Entry"; BuyEntrySubgraph.DrawStyle = DRAWSTYLE_ARROWUP; BuyEntrySubgraph.PrimaryColor = RGB(0, 255, 0); BuyEntrySubgraph.LineWidth = 2; BuyEntrySubgraph.DrawZeros = false; SellEntrySubgraph.Name = "Sell Entry"; SellEntrySubgraph.DrawStyle = DRAWSTYLE_ARROWDOWN; SellEntrySubgraph.PrimaryColor = RGB(255, 0, 0); SellEntrySubgraph.LineWidth = 2; SellEntrySubgraph.DrawZeros = false; FastSimpMovAvgSubgraph.Name = "Fast Moving Average"; FastSimpMovAvgSubgraph.DrawStyle = DRAWSTYLE_LINE; FastSimpMovAvgSubgraph.PrimaryColor = RGB(255, 255, 255); FastSimpMovAvgSubgraph.DrawZeros = false; FastSimpMovAvgSubgraph.LineWidth = 2; SlowSimpMovAvgSubgraph.Name = "Slow Moving Average"; SlowSimpMovAvgSubgraph.DrawStyle = DRAWSTYLE_LINE; SlowSimpMovAvgSubgraph.PrimaryColor = RGB(0, 255, 0); SlowSimpMovAvgSubgraph.DrawZeros = false; SlowSimpMovAvgSubgraph.LineWidth = 2; Enabled.Name = "Enabled"; Enabled.SetYesNo(0); sc.AllowMultipleEntriesInSameDirection = false; sc.MaximumPositionAllowed = 2; sc.SupportReversals = false; // This is false by default. sc.SendOrdersToTradeService = false; sc.AllowOppositeEntryWithOpposingPositionOrOrders = false; sc.SupportAttachedOrdersForTrading = false; sc.CancelAllOrdersOnEntriesAndReversals= false; sc.AllowEntryWithWorkingOrders = false; sc.CancelAllWorkingOrdersOnExit = true; // Only 1 trade for each Order Action type is allowed per bar. sc.AllowOnlyOneTradePerBar = true; //This needs to be set to true when a trading study uses trading functions. sc.MaintainTradeStatisticsAndTradesData = true; sc.AutoLoop = 1; sc.GraphRegion = 0; sc.FreeDLL = 0; return; } if (!Enabled.GetYesNo()) return; int OrderIndex = 0; while (true) { // Get the next order details structure. s_SCTradeOrder OrderDetails; if (sc.GetOrderByIndex(OrderIndex, OrderDetails) == SCTRADING_ORDER_ERROR) break; ++OrderIndex; // Skip if not a working order. if (!OrderDetails.IsWorking()) continue; // Skip if not an attached order. if (!OrderDetails.IsAttachedOrder()) continue; // Skip if not a stop order. if (OrderDetails.OrderTypeAsInt != SCT_ORDERTYPE_STOP) continue; //Modify order to same price. Since the price is the same, it will be ignored by the next line of code. This code only serves as an example of an order modification. double NewPrice = OrderDetails.Price1; //If modifying to the same price as previously, then do not perform the modification if(NewPrice == OrderDetails.LastModifyPrice1) continue; //Modify order s_SCNewOrder ModifyOrder; ModifyOrder.InternalOrderID = OrderDetails.InternalOrderID; ModifyOrder.Price1 = NewPrice; sc.ModifyOrder(ModifyOrder); } } 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: