Support Board
Date/Time: Sun, 19 Jan 2025 08:55:02 +0000
Post From: PositionData returns zero values
[2018-03-24 17:31:13] |
User257964 - Posts: 6 |
Dear SC support, for some reason PositionData structure contains and returns zero values after opening any long/short position in any of my scripts. Even when trying the sample script scsf_TradingExample from the tradingsystem.cpp: if (TradingAllowed && sc.CrossOver(Last, SimpMovAvgSubgraph) == CROSS_FROM_BOTTOM && sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED) { Result = (int)sc.BuyEntry(NewOrder); //Result = sc.BuyOrder(NewOrder); //If there has been a successful order entry, then draw an arrow at the low of the bar. if (Result > 0) { r_BuyEntryInternalOrderID = NewOrder.InternalOrderID; SCString InternalOrderIDNumberString; InternalOrderIDNumberString.Format("BuyEntry Internal Order ID: %d", r_BuyEntryInternalOrderID); sc.AddMessageToLog(InternalOrderIDNumberString, 0); BuyEntrySubgraph[sc.Index] = sc.Low[sc.Index]; } } // When there is a long position AND the Last price is less than the price the Buy Entry was filled at minus Stop Value, OR there is a long position AND the Last price is greater than the price the Buy Entry was filled at plus the Target Value. else if (PositionData.PositionQuantity > 0 && (LastTradePrice <= PositionData.AveragePrice - StopValue.GetFloat() || LastTradePrice >= PositionData.AveragePrice + TargetValue.GetFloat())) { Result = (int)sc.BuyExit(NewOrder); //If there has been a successful order entry, then draw an arrow at the high of the bar. if (Result > 0) { BuyExitSubgraph[sc.Index] = sc.High[sc.Index]; } } which I copy and paste, the output is the same. sc.MaintainTradeStatisticsAndTradesData set on true. Please advise. Thank you |