Login Page - Create Account

Support Board


Date/Time: Sat, 15 Mar 2025 07:37:52 +0000



Post From: s_SCPositionData Variable .OpenProfitLoss Does Not Return Correct Value On Sim Mode

[2022-07-13 07:24:30]
User36703 - Posts: 29
It does appear with a symbol for the same position of the symbol of the chart the trading study is on which is making the call. It does not matter which a specific one is applied. Short is always negative, long always positive.

  int iOrder = 0;
  s_SCTradeOrder entryOrderDetails;

  while (sc.GetOrderForSymbolAndAccountByIndex("", sc.SelectedTradeAccount, iOrder, entryOrderDetails) != SCTRADING_ORDER_ERROR) {
    iOrder++;
    if (entryOrderDetails.OrderStatusCode == SCT_OSC_FILLED) {    
      s_SCPositionData positionData;
      if (sc.GetTradePositionForSymbolAndAccount(positionData, entryOrderDetails.Symbol, sc.SelectedTradeAccount)){
....

I use simulaton mode for development and testing, but I can try out live mode as well if needed.

As Sierra Engeineer had suggested I tried build a workaround with sc.GetSymbolDataValue() function. I managed to get last price information and then I made calculation of Open PnL by myself. For me this workaround solves the problem in the moment.
Date Time Of Last Edit: 2022-07-13 07:35:31
imagePosDataES.png / V - Attached On 2022-07-13 06:42:58 UTC - Size: 46.77 KB - 127 views
imagePosDataNQ.png / V - Attached On 2022-07-13 06:43:03 UTC - Size: 47.67 KB - 127 views