Support Board
Date/Time: Tue, 13 May 2025 17:05:05 +0000
Post From: Multiple attached entry orders
[2018-05-20 22:55:48] |
|
We cannot reproduce the problem. Here is the test function which you can use as an example. SCSFExport scsf_ACSILTradingTest2(SCStudyInterfaceRef sc)
{ //Define references to the Subgraphs and Inputs for easy reference SCSubgraphRef BuyEntrySubgraph = sc.Subgraph[0]; SCSubgraphRef BuyExitSubgraph = sc.Subgraph[1]; SCSubgraphRef SellEntrySubgraph = sc.Subgraph[2]; SCSubgraphRef SellExitSubgraph = sc.Subgraph[3]; SCInputRef Enabled = sc.Input[0]; if (sc.SetDefaults) { // Set the study configuration and defaults. sc.GraphName = "Trading Test 2"; BuyEntrySubgraph.Name = "Buy Entry"; BuyEntrySubgraph.DrawStyle = DRAWSTYLE_ARROW_UP; BuyEntrySubgraph.PrimaryColor = RGB(0, 255, 0); BuyEntrySubgraph.LineWidth = 2; BuyEntrySubgraph.DrawZeros = false; BuyExitSubgraph.Name = "Buy Exit"; BuyExitSubgraph.DrawStyle = DRAWSTYLE_ARROW_DOWN; BuyExitSubgraph.PrimaryColor = RGB(255, 128, 128); BuyExitSubgraph.LineWidth = 2; BuyExitSubgraph.DrawZeros = false; SellEntrySubgraph.Name = "Sell Entry"; SellEntrySubgraph.DrawStyle = DRAWSTYLE_ARROW_DOWN; SellEntrySubgraph.PrimaryColor = RGB(255, 0, 0); SellEntrySubgraph.LineWidth = 2; SellEntrySubgraph.DrawZeros = false; SellExitSubgraph.Name = "Sell Exit"; SellExitSubgraph.DrawStyle = DRAWSTYLE_ARROW_UP; SellExitSubgraph.PrimaryColor = RGB(128, 255, 128); SellExitSubgraph.LineWidth = 2; SellExitSubgraph.DrawZeros = false; Enabled.Name = "Enabled"; Enabled.SetYesNo(0); Enabled.SetDescription("This input enables the study and allows it to function. Otherwise, it does nothing."); // This is false by default. Orders will be simulated. sc.SendOrdersToTradeService = false; sc.AllowMultipleEntriesInSameDirection = false; //This must be equal to or greater than the order quantities you will be submitting orders for. sc.MaximumPositionAllowed = 10000; sc.SupportReversals = true; sc.AllowOppositeEntryWithOpposingPositionOrOrders = true; // This variable controls whether to use or not use attached orders that are configured on the Trade Window for the chart. sc.SupportAttachedOrdersForTrading = false; //This variable controls whether to use the "Use Attached Orders" setting on the Trade Window for the chart sc.UseGUIAttachedOrderSetting = false; sc.CancelAllOrdersOnEntriesAndReversals = false; sc.AllowEntryWithWorkingOrders = false; sc.CancelAllWorkingOrdersOnExit = true; sc.AllowOnlyOneTradePerBar = false; //This needs to be set to true when a trading study uses trading functions. sc.MaintainTradeStatisticsAndTradesData = true; sc.AutoLoop = true; sc.GraphRegion = 0; // During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance. sc.FreeDLL = 0; return; } //These must be outside of the sc.SetDefaults code block since they have a dependency upon an actual chart object existing sc.SupportTradingScaleIn = 0; sc.SupportTradingScaleOut = 0; if (!Enabled.GetYesNo()) return; if (sc.LastCallToFunction) return;//nothing to do // Run the below code only on the last bar if (sc.Index < sc.ArraySize - 1) return; sc.AllowMultipleEntriesInSameDirection = true; sc.AllowOnlyOneTradePerBar = false; sc.AllowEntryWithWorkingOrders = true; sc.SupportAttachedOrdersForTrading = true; sc.CancelAllWorkingOrdersOnExit = true; s_SCPositionData PositionData; sc.GetTradePosition(PositionData); if (PositionData.PositionQuantity == 0) { s_SCNewOrder NewOrder; NewOrder.OrderQuantity = 1; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.AttachedOrderStop1Type = SCT_ORDERTYPE_TRAILING_STOP; NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; NewOrder.Stop1Offset = 10 * sc.TickSize; sc.BuyEntry(NewOrder); s_SCNewOrder NewOrder1; NewOrder1.OrderQuantity = 1; NewOrder1.OrderType = SCT_ORDERTYPE_MARKET; NewOrder1.AttachedOrderStop1Type = SCT_ORDERTYPE_TRAILING_STOP; NewOrder1.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; NewOrder1.Stop1Offset = 15 * sc.TickSize; sc.BuyEntry(NewOrder1); } } 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 |