Login Page - Create Account

Support Board


Date/Time: Wed, 19 Nov 2025 16:19:02 +0000



[Programming Help] - sc.GetTradePosition() returns PositionQuantity=0 in Simulation Mode with Symbol Mapping

View Count: 45

[2025-11-18 23:52:57]
chikko - Posts: 3
I'm experiencing an issue with sc.GetTradePosition() returning incorrect position data when using Trade Simulation Mode with symbol mapping (charting one symbol while trading another).

Setup:
- Trade Simulation Mode: ON (not using Trade Evaluator)
- Chart Symbol: NQZ25-CME/MNQZ25-CME[M] (charting NQ, trading MNQ)
- Trades are correctly being placed on [Sim]MNQZ25-CME as shown in Trade Activity Log
- Study using sc.SendOrdersToTradeService = !sc.GlobalTradeSimulationIsOn;


s_SCPositionData PositionData;
int result = sc.GetTradePosition(PositionData);

if (PositionData.PositionQuantity == 0)
{
sc.AddMessageToLog("No open position. Cannot add TP/SL.", 1);
sc.MenuEventID = 0;
return;
}

SCString positionInfo;
positionInfo.Format("Position Details: Quantity=%d, OpenPL=%.2f, DailyPL=%.2f, AverageFillPrice=%.2f",
PositionData.PositionQuantity,
PositionData.OpenProfitLoss,
PositionData.DailyProfitLoss,
PositionData.AveragePrice);
sc.AddMessageToLog(positionInfo, 0);



Actual Output:
2025-11-18 21:07:39.522 | Chart: NQZ25-CME/MNQZ25-CME[M] 5 Min #5 | Study: Smart Trade Manager | Position Details: Quantity=0, OpenPL=-103.50, DailyPL=442.20, AverageFillPrice=24675.00

Problem:
PositionQuantity returns 0 despite having an active simulated position. However, other fields like OpenPL, DailyPL, and AverageFillPrice show correct data, indicating there IS a position AND i can clearly see the position open in the chart visually.

The Trade Activity Log confirms trades are filling on [Sim]MNQZ25-CME, but sc.GetTradePosition() called from a chart with symbol NQZ25-CME/MNQZ25-CME[M] is not retrieving the position quantity.

Attempted Solutions:
1. Used sc.GetTradePositionForSymbolAndAccount() with [Sim]MNQZ25-CME - still returns Quantity=0
2. Used sc.GetTradeSymbol() to get the trading symbol - correctly returns MNQZ25-CME, but querying [Sim]MNQZ25-CME or MNQZ25-CME both returns Quantity=0

Documentation Reference:
According to https://www.sierrachart.com/index.php?page=doc/ACSILTrading.html#scGetTradePosition:

"For simulated Trade Positions data, the data comes from the internal Trades list of a chart."

Questions:
1. Is this expected behavior when charting one symbol but trading another in simulation mode?
2. How should sc.GetTradePosition() or sc.GetTradePositionForSymbolAndAccount() (the latter one probably doesn't even work in sim mode because we don't have an account?) be used to retrieve simulated position data when the chart symbol differs from the trading symbol?
3. Why does PositionQuantity return 0 while other position fields (OpenPL, AverageFillPrice) contain valid data?

Is there a different approach needed for accessing simulated position data with symbol mapping, or is this a potential bug?


Semi-Related, but same problem: Position quantity with GetTradePosition is 0 on Teton Order Routing

It seems like the position quantity is broken in simulation mode. I can't switch to the trading evaluator service at the moment, because i am still relying on delayed EUREX data and your docs are saying this won't work.

Thank you for your assistance.
imageImage.png / V - Attached On 2025-11-18 23:51:38 UTC - Size: 574.16 KB - 9 views
Attachment Deleted.
[2025-11-19 08:56:59]
User431178 - Posts: 813
Position quantity is clearly not zero, otherwise your positionInfo message would never be printed due to the early return on zero position...


positionInfo.Format("Position Details: Quantity=%d, OpenPL=%.2f, DailyPL=%.2f, AverageFillPrice=%.2f",
PositionData.PositionQuantity,
PositionData.OpenProfitLoss,
PositionData.DailyProfitLoss,
PositionData.AveragePrice);

The error is in how you format the positionInfo string.
Position quantity is not integer type - Automated Trading From an Advanced Custom Study: [Type: double] PositionQuantity
Change "Quantity=%d" to "Quantity=%f" (or cast PositionData.PositionQuantity to integer), problem solved.
[2025-11-19 13:37:19]
chikko - Posts: 3
You are right, in this case the formatting was the issue - its always something stupid..
There is another problem in my code, which seems to be unrelated.
I was trying to debug whats going, but since i messed up the format, this was completely misleading.

Thanks!

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account