Support Board
Date/Time: Fri, 27 Dec 2024 01:45:24 +0000
Opening Stock Option position from a Stock Chart
View Count: 3255
[2015-12-08 21:39:10] |
User99735 - Posts: 234 |
Hi, Am trying to open a position on AAPL option from an AAPL chart as described in the help page https://www.sierrachart.com/index.php?page=doc/doc_ACSILTrading.html#SubmittingOrdersDifferentSymbolAccount using an IB account. However the orders are getting opened for AAPL stock even when the order option symbol is AAPL-OPT-20151211-118-C-SMART-100-USD. Anything addtional to be done apart from is present in the sample code - scsf_TradingExampleOrdersForDifferentSymbolAndAccount? Regards Vivek |
[2015-12-08 22:07:23] |
Sierra Chart Engineering - Posts: 104368 |
Can you provide us the particular block of code you are using to the submit the order.
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-12-08 22:11:46] |
User99735 - Posts: 234 |
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = 1; //optionPos->Qty[CALLPUT]; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.TimeInForce = SCT_TIF_DAY; //NewOrder.Price1 = (double) optionPos->OptionEntryPrice[CALLPUT]; NewOrder.OCOGroup1Quantity = NewOrder.OrderQuantity; if (PermData->OrderData[TargetOffset] > 0) NewOrder.Target1Offset = (double)PermData->OrderData[TargetOffset]; if (PermData->OrderData[StopOffset] > 0) NewOrder.Stop1Offset = (double)PermData->OrderData[StopOffset]; NewOrder.Symbol = "AAPL-OPT-20151211-118-C-SMART-100-USD";//optionPos->OptionName[CALLPUT]; NewOrder.TradeAccount = sc.SelectedTradeAccount; int result = -3; char msg[1000]; if (optionPos->LongShort[CALLPUT]) { result = sc.BuyEntry(NewOrder); } else { result = sc.SellEntry(NewOrder); } and in the sc.defaults section the following variables are set sc.MaintainTradeStatisticsAndTradesData = true; sc.AllowOnlyOneTradePerBar = false; sc.AllowMultipleEntriesInSameDirection = true; //sc.MaximumPositionAllowed = 20; sc.SupportReversals = true; sc.SupportAttachedOrdersForTrading = false; sc.AllowOppositeEntryWithOpposingPositionOrOrders = true; sc.CancelAllOrdersOnEntriesAndReversals = true; sc.AllowEntryWithWorkingOrders = true; sc.CancelAllWorkingOrdersOnExit = true; sc.UseGUIAttachedOrderSetting = false; sc.ReceiveNotificationsForChangesToOrdersPositionsForAnySymbol = true; |
[2015-12-08 22:47:18] |
Sierra Chart Engineering - Posts: 104368 |
We see the problem. You need to use one of the following two functions to submit the order: sc.BuyOrder sc.SellOrder 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-12-09 18:02:43] |
User99735 - Posts: 234 |
Hi, Thanks for suggestion. Even after replacing sc.BuyEntry and sc.SellEntry with sc.BuyOrder and sc.SellOrder, orders are being opened on the Chart symbol. Regards Vivek |
[2015-12-09 18:28:38] |
Sierra Chart Engineering - Posts: 104368 |
We tested this using that symbol in Sierra Chart Trade Simulation Mode and the orders got submitted for the specified symbol: Entry Time Last Activity Time Symbol Status Internal Order ID Order Type Buy/Sell Open/Close Order Quantity Price Price 2 Filled Quantity Average Fill Price Parent Internal Order ID Time in Force Good Till DateTime Service Order ID Trade Account Link ID OCO ID LastOrderActionSource Client Order ID Exchange Order ID Text Tag TrailOrderOffset TrailOrderStepAmount
2015-12-09 13:25:55 2015-12-09 13:25:55 [Sim]AAPL-OPT-20151211-118-C-SMART-100-USD Pending Child 12253 Stop Sell Close 0 2035.00000 0.00000 0 0.00000 12251 Day Sim1 0 12252 Auto-trade: ESZ15 [M] 1 Min #1 | Trading Example: Orders for Different Symbol and Account | sc.SubmitOrder | Attached Order 0.00000 0.00000 2015-12-09 13:25:55 2015-12-09 13:25:55 [Sim]AAPL-OPT-20151211-118-C-SMART-100-USD Pending Child 12252 Limit Sell Close 0 2039.00000 0.00000 0 0.00000 12251 Day Sim1 0 12252 Auto-trade: ESZ15 [M] 1 Min #1 | Trading Example: Orders for Different Symbol and Account | sc.SubmitOrder | Attached Order 0.00000 0.00000 2015-12-09 13:25:55 2015-12-09 13:25:55 [Sim]AAPL-OPT-20151211-118-C-SMART-100-USD Open 12251 Limit Buy Open 1 2036.75000 0.00000 0 0.00000 0 Day 12251 Sim1 0 0 Simulated order accepted 0.00000 0.00000 Make absolutely certain, that the code changes are actually being used for the trading study applied to the chart. We can think of no reason why this would go wrong. 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: 2015-12-09 18:29:33
|
[2015-12-09 21:00:20] |
User99735 - Posts: 234 |
Hi, Did you test with IB as broker? I ran example scsf_TradingExampleOrdersForDifferentSymbolAndAccount on a AAPL chart with const char* SymbolToTrade set to "AAPL-OPT-20151211-118-C-SMART-100-USD", and am getting same results ie order is placed on AAPL instead of the option. Regards Vivek |
[2015-12-09 21:06:17] |
Sierra Chart Engineering - Posts: 104368 |
No, but it would not matter anyway. Go to the Trade >> Trade Activity Log >> Trade Activity tab. What is the symbol of the order submitted from the automated trading system? It should be what you have specified. Here are instructions to use the Trade Activity Log: https://www.sierrachart.com/index.php?page=doc/doc_TradeActivityLog.php#ViewingHistoricalTA 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-12-09 21:14:36] |
User99735 - Posts: 234 |
Symbol is AAPL
|
[2015-12-09 21:24:14] |
Sierra Chart Engineering - Posts: 104368 |
Enable Trade >> Trade Simulation Mode On. Test the following trading system on a chart of AAPL. The study has two Inputs. Set the Enabled Input to Yes. Set the Reference Chart to reference the chart the trading system is applied to. What symbol is the submitted order for? SCSFExport scsf_TradingExampleOrdersForDifferentSymbolAndAccount(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]; SCInputRef ReferenceChartForPrice = sc.Input[1]; if (sc.SetDefaults) { // Set the study configuration and defaults. sc.GraphName = "Trading Example: Orders for Different Symbol and Account"; sc.StudyDescription = "This function demonstrates submitting, modifying and canceling an order for a different symbol than the chart the trading study is applied to"; 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."); ReferenceChartForPrice.Name = "Reference Chart For Price"; ReferenceChartForPrice.SetChartNumber(0); // This is false by default. Orders will be simulated. sc.SendOrdersToTradeService = false; // These variables are not used when trading another Symbol and/or Trade Account compared to what the chart is set to. sc.AllowMultipleEntriesInSameDirection = true; sc.MaximumPositionAllowed = 10000; sc.SupportReversals = true; sc.AllowOppositeEntryWithOpposingPositionOrOrders = true; sc.SupportAttachedOrdersForTrading = false; sc.UseGUIAttachedOrderSetting = false; sc.CancelAllOrdersOnEntriesAndReversals= true; 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.ReceiveNotificationsForChangesToOrdersPositionsForAnySymbol = true; sc.AutoLoop = true; sc.GraphRegion = 0; 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. They are not used in this example. sc.SupportTradingScaleIn = 0; sc.SupportTradingScaleOut = 0; int& r_BarIndexOfOrder = sc.GetPersistentInt(1); int& r_InternalOrderID = sc.GetPersistentInt(2); int& r_PerformedOrderModification = sc.GetPersistentInt(3); if (!Enabled.GetYesNo()) { r_BarIndexOfOrder = 0; r_InternalOrderID = 0; r_PerformedOrderModification = 0; return; } if ( sc.LastCallToFunction ) return;//nothing to do if (sc.ChartIsDownloadingHistoricalData(ReferenceChartForPrice.GetChartNumber()) || sc.IsFullRecalculation //|| sc.ServerConnectionState != SCS_CONNECTED ) return; // Run the below code only on the last bar if (sc.Index < sc.ArraySize-1) return; SCFloatArray LastPriceArrayFromChartToTrade; sc.GetChartArray ( ReferenceChartForPrice.GetChartNumber() , SC_LAST , LastPriceArrayFromChartToTrade ); if (LastPriceArrayFromChartToTrade.GetArraySize() == 0) return; int LastIndexOfArrayFromChartToTrade = LastPriceArrayFromChartToTrade.GetArraySize() - 1; const char* SymbolToTrade = "AAPL-OPT-20151211-118-C-SMART-100-USD";//"NQZ5"; s_SCPositionData PositionData; sc.GetTradePositionForSymbolAndAccount(PositionData, SymbolToTrade, sc.SelectedTradeAccount); if (PositionData.PositionQuantity == 0 && PositionData.WorkingOrdersExist == 0 && r_InternalOrderID == 0) { // Create an s_SCNewOrder object. s_SCNewOrder NewOrder; NewOrder.OrderQuantity = 1; NewOrder.OrderType = SCT_ORDERTYPE_LIMIT; NewOrder.TimeInForce = SCT_TIF_DAY; NewOrder.Price1 = LastPriceArrayFromChartToTrade[LastIndexOfArrayFromChartToTrade] - 10 * sc.TickSize; //Specify a Target and a Stop with 8 tick offsets. //Only 1 Target and 1 Stop can be supported when trading //a Symbol and Trade Account different than the chart the //trading system study is applied to. NewOrder.Target1Offset = 8*sc.TickSize; NewOrder.Stop1Offset = 8*sc.TickSize; // If this is left at the default of 0, then it will be automatically set. NewOrder.OCOGroup1Quantity = 1; NewOrder.Symbol = SymbolToTrade; NewOrder.TradeAccount = sc.SelectedTradeAccount; int Result = sc.BuyOrder(NewOrder); if (Result > 0) { r_BarIndexOfOrder = sc.Index; r_InternalOrderID = NewOrder.InternalOrderID; } } else if (r_InternalOrderID != 0) { s_SCTradeOrder ExistingOrderDetails; if (sc.GetOrderByOrderID(r_InternalOrderID, ExistingOrderDetails)) { //If original submitted order is still working. if (IsWorkingOrderStatus(ExistingOrderDetails.OrderStatusCode) ) { //When 2 new bars added to chart since the original order submission if (r_PerformedOrderModification == 0 && sc.Index > r_BarIndexOfOrder + 1) { //Modify the order s_SCNewOrder ModifyOrder; ModifyOrder.InternalOrderID = r_InternalOrderID; ModifyOrder.Price1 = LastPriceArrayFromChartToTrade[LastIndexOfArrayFromChartToTrade] - 12 * sc.TickSize; if (sc.ModifyOrder(ModifyOrder) > 0) r_PerformedOrderModification = 1; } //When 3 new bars added to chart since the original order submission else if (sc.Index > r_BarIndexOfOrder + 2) { //Cancel the order sc.CancelOrder(r_InternalOrderID); } } } } } 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: 2015-12-09 21:25:40
|
[2015-12-10 00:01:04] |
Sierra Chart Engineering - Posts: 104368 |
Something we just realized in our testing is that you would be encountering an exception when submitting an order for an unknown symbol like that option symbol. So we do not even think this would even be working at all from your side to begin with. We have this fixed and we will have a new release tomorrow. 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-12-10 08:16:43] |
User99735 - Posts: 234 |
Hi, Thanks for the update. Look forward to the update. "would be encountering an exception when submitting an order for an unknown symbol like that option symbol." This is not clear, why would the option symbol be unknown, I am able to open a chart for the option symbol." Regards Vivek |
[2015-12-10 08:37:00] |
Sierra Chart Engineering - Posts: 104368 |
The option symbol is not listed in Global Settings >> Symbol Settings. That is where it is unknown.
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-12-10 08:40:49] |
User99735 - Posts: 234 |
Will your fix take care of this, or I need to add them manually?
|
[2015-12-10 09:18:01] |
Sierra Chart Engineering - Posts: 104368 |
There does not need to be Symbol Settings for options. Also, when you update to the newest version, it is not going to solve the originally reported issue. There is something else causing it and the only reasonable explanation, has something to do with your code but it is not clear what that is at this time. So we have to go through a step-by-step process to isolate the problem. 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-12-10 09:40:39] |
User99735 - Posts: 234 |
As I mentioned earlier, I also tried running the sample program scsf_TradingExampleOrdersForDifferentSymbolAndAccount, which is also giving similar results ie failing.
|
[2015-12-10 10:09:02] |
Sierra Chart Engineering - Posts: 104368 |
Did you test it Trade Simulation Mode? Although that should not make a difference. If necessary you can replay the chart. However, if you are getting the same result where the order is submitted using the symbol of the chart, then really this is impossible unless you are running an older version of Sierra Chart. Confirm the version of Sierra Chart you are running. 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: 2015-12-10 10:11:02
|
[2015-12-10 13:41:43] |
User99735 - Posts: 234 |
Did you test it Trade Simulation Mode? >> Yes However, if you are getting the same result where the order is submitted using the symbol of the chart, then really this is impossible unless you are running an older version of Sierra Chart. Confirm the version of Sierra Chart you are running. >> Am working with build 1336 Screenshot of the Trade Activity log enclosed |
Attachment Deleted. |
[2015-12-11 18:28:41] |
User99735 - Posts: 234 |
Hi, Any update. Did some tests with the sample code scsf_TradingExampleOrdersForDifferentSymbolAndAccount. Worked fine with another stock symbol 'TSLA' from an 'AAPL' chart, but does not work with option 'AAPL-OPT-20151211-118-C-SMART-100-USD' Regards Vivek |
[2015-12-11 19:13:55] |
Sierra Chart Engineering - Posts: 104368 |
We have not had a chance to look into this again. We will do some testing again now.
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-12-11 19:44:01] |
Sierra Chart Engineering - Posts: 104368 |
The problem has been discovered. We should have tested using the symbol AAPL on the chart. There is a low-level string comparison issue in ACSIL. We are fixing this now. 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: 2015-12-11 19:44:22
|
[2015-12-11 19:45:21] |
User99735 - Posts: 234 |
ok Great, Thanks. Kindly update me when the update is ready for download.
|
[2015-12-11 19:56:04] |
Sierra Chart Engineering - Posts: 104368 |
Should be ready in about 15 to 20 minutes. We will let you know.
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-12-11 20:37:03] |
Sierra Chart Engineering - Posts: 104368 |
Version 1338 has now been released. Update with Help >> Download Prerelease. It will now work properly and submit the order for the correct symbol.
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-12-12 01:52:35] |
User99735 - Posts: 234 |
Hi, Thanks, orders are going through. However, in Sim mode only LIMIT orders are being placed, if I try to do MARKET orders, the orders are getting rejected, ie Buy/SellOrder function is returning a -ve number. ( order being opened on a option ) Regards, Vivek |
To post a message in this thread, you need to log in with your Sierra Chart account: