Support Board
Date/Time: Sat, 05 Jul 2025 15:39:02 +0000
Post From: Delay with the function sc.GetTradePositionForSymbolAndAccount / the struct s_SCPosition
[2021-01-19 18:34:16] |
User869657 - Posts: 31 |
Hi SC team, We have noticed a delay with the function sc.GetTradePositionForSymbolAndAccount / the struct s_SCPositionData for which we would need your opinion please. Taking the following simple example to illustrate : SCString MessageString; s_SCPositionData PositionData; sc.GetTradePositionForSymbolAndAccount(PositionData, symbolToTrade.GetString(), tradeAccount.GetString()); if (PositionData.PositionQuantity == 0) { MessageString.Format("PositionData.PositionQuantity == 0"); sc.AddMessageToLog(MessageString, 0); s_SCNewOrder openOrder; openOrder.OrderQuantity = 1; openOrder.Symbol = symbolToTrade.GetString(); openOrder.TradeAccount = tradeAccount.GetString(); int resultOrder = sc.BuyOrder(openOrder); if (resultOrder > 0) { sc.GetTradePositionForSymbolAndAccount(PositionData, symbolToTrade.GetString(), tradeAccount.GetString()); SCString MessageString; MessageString.Format("Entry long successful. Current quantity is %.0f", PositionData.PositionQuantity); sc.AddMessageToLog(MessageString, 0); } } The log then shows : Chart: FDAXH21-EUREX [CBV][M] 5 Min #1 | Study: $18_Automated_Trading_via_SC_104 | PositionData.PositionQuantity == 0 | 2021-01-19 16:33:30.189 Chart: FDAXH21-EUREX [CBV][M] 5 Min #1 | Study: $18_Automated_Trading_via_SC_104 | Entry long successful. Current quantity is 0 | 2021-01-19 16:33:30.190 Chart: FDAXH21-EUREX [CBV][M] 5 Min #1 | Study: $18_Automated_Trading_via_SC_104 | PositionData.PositionQuantity == 0 | 2021-01-19 16:33:30.412 Chart: FDAXH21-EUREX [CBV][M] 5 Min #1 | Study: $18_Automated_Trading_via_SC_104 | Entry long successful. Current quantity is 1 | 2021-01-19 16:33:30.412 As you can see above, the first trade has been successfully entered but PositionData shows a PositionQuantity that is still 0. SC goes through these instructions once more time and opens a 2nd trade. After which the instruction if (PositionData.PositionQuantity == 0) is finally false and no more trades are taken. But the end result is 2 trades opened when the goal was to open only one. We would like to point out that this issue does not happen everytime but quite often though. Could you please let us know if this is expected / something you have ever seen ? Why is there such a delay for the struct s_SCPositionData to be filled ? Do we need to adjust a setting somewhere ? FYI, if needed for your investigation, the study is applied on the Dax fut, taking trades on the FXCM GER30 CFD (Service = FXCM Live Trading, server = FXCM LTD EURCFDREAL Server). The version used is the 2215 As always, many thanks for your help. |