Support Board
Date/Time: Wed, 02 Jul 2025 10:44:07 +0000
Delay with the function sc.GetTradePositionForSymbolAndAccount / the struct s_SCPosition
View Count: 554
[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. |
[2021-01-19 20:43:09] |
|
One thing obvious is that you did not specify the order type for this structure: s_SCNewOrder openOrder;
So the order probably did not fill right away. And the other thing, is that in the case of live trading, there will be a delay with any order filling and getting a position report. That should be obvious. You are not going to get any fill immediately. That is impossible. 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: 2021-01-19 20:46:40
|
To post a message in this thread, you need to log in with your Sierra Chart account: