Support Board
Date/Time: Fri, 26 Apr 2024 04:55:13 +0000
[Programming Help] - Order.Stop1InternalOrderID = 0 in LIVE trading?
View Count: 642
[2019-09-03 06:19:21] |
tomas262 - Posts: 135 |
I am adjusting Stop1Order for a trade open with ACSIL. When using SIM / REPLAY mode everything works great. Once a trade is open Stop1InternalOrderID is set for example to value 14695 so ID is non-zero and order can be modified successfully But when I switch to live trading and open a trade with the same code Stop1InternalOrderID is always 0 so the order cannot be selected to modify With the very same code what could be the reason? Trade LIVE & REPLAY screenshot attached Also attaching executed orders table with IDs shown This opened the sell trade: s_SCNewOrder NewOrder; NewOrder.OrderQuantity = OCO1Size.GetInt() + OCO2Size.GetInt() + OCO3Size.GetInt(); NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; int Result = (int)sc.SellEntry(NewOrder); if (Result > 0) { EntryOrderID = NewOrder.InternalOrderID; Target1OrderID = NewOrder.Target1InternalOrderID; Stop1OrderID = NewOrder.Stop1InternalOrderID; } This is how I move to B/E // Get and move the existing SL 1 order s_SCTradeOrder ExistingStopOrder1; if (sc.GetOrderByOrderID(Stop1OrderID, ExistingStopOrder1) != SCTRADING_ORDER_ERROR) { if (IsWorkingOrderStatus(ExistingStopOrder1.OrderStatusCode)) { double NewStop = 0.0; if (ExistingStopOrder1.BuySell == BSE_SELL) { NewStop = PositionData.AveragePrice + (double)BE1OffsetTicks.GetInt() * sc.TickSize; } s_SCNewOrder ModifyStopOrder1; ModifyStopOrder1.InternalOrderID = Stop1OrderID; ModifyStopOrder1.Price1 = NewStop; if (sc.ModifyOrder(ModifyStopOrder1) != SCTRADING_ORDER_ERROR) { logMessage.Format("SL 1 order moved to BE"); if (LogMessages.GetYesNo() == 1) sc.AddMessageToLog(logMessage, 1); } else { logMessage.Format("Error modifying SL 1 order, ID: %u", Stop1OrderID); if (LogMessages.GetYesNo() == 1) sc.AddMessageToLog(logMessage, 1); } } moveBE1triggered = 1; } Thanks for your great support! Date Time Of Last Edit: 2019-09-03 06:27:42
|
live-trade.png / V - Attached On 2019-09-03 06:16:44 UTC - Size: 141.33 KB - 231 views sim-trade.png / V - Attached On 2019-09-03 06:16:48 UTC - Size: 158.84 KB - 237 views orders-live.png / V - Attached On 2019-09-03 06:22:32 UTC - Size: 139.44 KB - 255 views |
[2019-09-03 11:30:25] |
tomas262 - Posts: 135 |
Seems the code is working differently in live mode - executing part of code which resets IDs to 0. Does not happen in SIM. Very strange
|
reset-0.png / V - Attached On 2019-09-03 11:30:14 UTC - Size: 144.8 KB - 242 views |
[2019-09-03 13:08:34] |
tomas262 - Posts: 135 |
Solved, found a glitch within the code, strangely did not happen on sim
|
To post a message in this thread, you need to log in with your Sierra Chart account: