Support Board
Date/Time: Fri, 10 Jan 2025 16:26:17 +0000
Post From: ACSIL - Chart Replay and submitting order for another symbol (Market Order never Fills)
[2016-09-09 08:42:49] |
William O - Posts: 16 |
I have a study that submits a market order for another symbol during a chart replay. The market order is successfully submitted using sc.SellOrder. However, this order never fills. I can pull up the Trade Orders and Positions window and see that the order was submitted as a market order and that it is open but not filled. For example, if I run the study code provided below in an ESZ16 chart replay I get this problem. I'm running this study on the ESZ16 chart and submitting a sell order for the NQZ16 symbol. Please let me know if I'm doing something wrong or how to fix this problem. Thanks for your support! SCSFExport scsf_TradingOnAnotherChart(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { // Set the study configuration and defaults. sc.GraphName = "Chart Replay: Trading Another Chart"; sc.StudyDescription = ""; sc.SendOrdersToTradeService = false; 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; } const char * OtherSymbol = "NQZ16"; const char * TradeAccount = "Sim1"; s_SCPositionData OtherPositionData; int returnval = sc.GetTradePositionForSymbolAndAccount(OtherPositionData, OtherSymbol, TradeAccount); if (!sc.IsFullRecalculation && sc.IsReplayRunning() && OtherPositionData.PositionQuantity == 0 && !OtherPositionData.WorkingOrdersExist) { int quantity = 1; s_SCNewOrder o; o.OrderQuantity = quantity; o.OrderType = SCT_MARKET; o.Symbol = OtherSymbol; o.TimeInForce = SCT_TIF_DAY; o.TradeAccount = TradeAccount; int result = sc.SellOrder(o); if (result <= 0)//order was not accepted { sc.AddMessageToLog(sc.GetTradingErrorTextMessage(result), 0); } } } |