Support Board
Date/Time: Sat, 23 Nov 2024 14:06:28 +0000
Scaling in using a study
View Count: 1730
[2013-07-14 16:31:43] |
flyboy615 - Posts: 56 |
Hi, What I would like to do is to be able to scale into a trade via a study. The initial order would use an configuration file for entry and any additional entries, using buy stop limit or sell stop limit, will add to the position, target and stop. I can achieve this manually via the trade dome but this approach doesn't seem to work via a study. If I just set SupportTradingScaleIn to true I get multiple stops and targets based on the new entry. If I disable SupportAttachedOrdersForTrading, I can add to the position but the quantities for the stops and targets are not increased. What I’m doing is to enable SupportAttachedOrdersForTrading for the first order; Disable it after the order is placed and enabling SupportTradingScaleIn for the later entries. SupportTradingScaleIn is done just prior to each additional entry since SupportTradingScaleIn has to be done outside of the sc.defaults. I have tried various combinations of settings without any effect. Is there a way to emulate the scalein ability found in the dome? Thanks Date Time Of Last Edit: 2013-07-14 16:43:04
|
[2013-07-14 16:41:59] |
vegasfoster - Posts: 444 |
If you turn on chart trading for the chart where the study is applied to, click M and check scale-in and scale-out, and check the attached orders box, then automated entries will work the same as regular entries, i.e. first order will have stops and targets and subsequent orders will adjust the amounts of the stops and targets.
|
[2013-07-14 16:47:48] |
flyboy615 - Posts: 56 |
In this case both were already checked. As I mentioned this worked manually. I just can't seem to get the combination right inside of the study. It just adds additional targets and stops or just adds to the position and not to the target and stops. Thanks |
[2013-07-14 22:59:03] |
Sierra Chart Engineering - Posts: 104368 |
You need to enable: sc.SupportAttachedOrdersForTrading = 1; sc.SupportTradingScaleIn = 1; Here is the code which demonstrates this successfully works: SCSFExport scsf_ACSILTradingTest(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"; BuyEntrySubgraph.Name = "Buy Entry"; BuyEntrySubgraph.DrawStyle = DRAWSTYLE_ARROWUP; BuyEntrySubgraph.PrimaryColor = RGB(0, 255, 0); BuyEntrySubgraph.LineWidth = 2; BuyEntrySubgraph.DrawZeros = false; BuyExitSubgraph.Name = "Buy Exit"; BuyExitSubgraph.DrawStyle = DRAWSTYLE_ARROWDOWN; BuyExitSubgraph.PrimaryColor = RGB(255, 128, 128); BuyExitSubgraph.LineWidth = 2; BuyExitSubgraph.DrawZeros = false; SellEntrySubgraph.Name = "Sell Entry"; SellEntrySubgraph.DrawStyle = DRAWSTYLE_ARROWDOWN; SellEntrySubgraph.PrimaryColor = RGB(255, 0, 0); SellEntrySubgraph.LineWidth = 2; SellEntrySubgraph.DrawZeros = false; SellExitSubgraph.Name = "Sell Exit"; SellExitSubgraph.DrawStyle = DRAWSTYLE_ARROWUP; 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 go to the simulation system always. sc.SendOrdersToTradeService = false; sc.AllowMultipleEntriesInSameDirection = true; sc.MaximumPositionAllowed = 20; sc.SupportReversals = false; sc.AllowOppositeEntryWithOpposingPositionOrOrders = false; // This variable controls whether to use or not use attached orders that are configured on the Trade Window for the chart. sc.SupportAttachedOrdersForTrading = true; //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 = true; 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 sc.SupportTradingScaleIn = 1; 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; // Create an s_SCNewOrder object. s_SCNewOrder NewOrder; NewOrder.OrderQuantity = 2; NewOrder.OrderType = SCT_MARKET; int Result =sc.BuyEntry(NewOrder); if (Result > 0) //If there has been a successful order entry { BuyEntrySubgraph[sc.Index] = sc.Low[sc.Index]; } } 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: 2013-07-14 22:59:43
|
[2013-07-15 01:04:25] |
flyboy615 - Posts: 56 |
Hi, In the case of using a configuration file with the settings "Support Scale-in" and "Use attached orders" both checked in the configuration. In the study.... sc.TradeWindowConfigFileName = TWConfigFile; Both the recommended settings set to true; Using a Buy stop limit for all entries; Example: NewOrder.OrderQuantity = EntryQuantity.GetInt(); NewOrder.OrderType = SCT_STOPLIMIT; NewOrder.LimitPrice = BuyStop; NewOrder.StopPrice = BuyStop; This combination creates multiple entries each with their own stop and target and doesn't add to the original position. I will use the above code to test further tomorrow. Thanks. |
[2013-07-15 23:47:35] |
flyboy615 - Posts: 56 |
Hi, My issue is that I wanted to set the next scale in level after the order as placed (BuyStopLimit)and prior to the initial order being filled. I have modified the above code to demonstrate what I wanted to do if you are interested. Is there any way to scale in with using advanced orders ( limit orders ) for the initial trade and the next level without having the initial order filled first? Thanks |
[2013-07-16 00:16:44] |
Sierra Chart Engineering - Posts: 104368 |
Yes. You simply need to modify order quantity of the existing order that has not yet filled and increase its quantity. Do not submit a new order. Its own child orders will be set to the correct quantities once that order fills.
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: 2013-07-16 00:16:59
|
To post a message in this thread, you need to log in with your Sierra Chart account: