Login Page - Create Account

Support Board


Date/Time: Sun, 29 Mar 2026 18:48:52 +0000



[Programming Help] - Position Data Empty

View Count: 272

[2026-02-11 21:07:59]
Gradient - Posts: 199
Hi,

I'm attempting to sum the PnL for different symbols across different charts.

I created a s_PositionData structure for each symbol.

I've noticed that the PnL for the chart that the study is applied to has the correct PnL, but the PnL for the opposite chart is incorrect.

For example,

Given 2 charts, A and B, each chart is performing the same calculation. The PnL for each respective chart is correct but each chart's calculation of the opposite chart's PnL is incorrect.

This underspecifies the total pnl (i.e. sum of both charts PnL)

I've attached a screenshot of the issue.

In the screenshot, Pos represents the open quantity for the current symbol, PnL is the total pnl across each symbol(i.e. each chart), CPnL is the current symbol's pnl, OPnL is the pnl for the other chart's symbol.

Given that PnL(i.e. total pnl) is the sum of CPnL(current chart's pnl) and OPnL(other chart's pnl), it's apparent that the OPnL is zero.

How can this be?

Also, OpenPnL is some extremely large number that is incorrect.


Code Snippet

SCString otherSymbol=sc.GetChartSymbol(otherChartID.GetInt());

//Declare Position Data Structures
s_SCPositionData PositionData;
s_SCPositionData otherPositionData;

//Initialize Position Data Structures
sc.GetTradePosition(PositionData);
sc.GetTradePositionForSymbolAndAccount(otherPositionData,otherSymbol,sc.SelectedTradeAccount);

//Declare PnL Variables
double pnlTotal;
double currentSymbolPnL;
double OpenPnL;
double otherSymbolPnL;

OpenPnL=PositionData.TradeStatsOpenProfitLoss;
currentSymbolPnL=PositionData.DailyProfitLoss;
otherSymbolPnL=otherPositionData.DailyProfitLoss;
pnlTotal=currentSymbolPnL+otherSymbolPnL;

//STORING CURRENT POSITION QUANTITY
sc.Subgraph[52][sc.Index]=PositionData.PositionQuantity;
  
//STORING PNL TOTAL
sc.Subgraph[53][sc.Index]=pnlTotal;
  
//STORING CURRENT AND OTHER SYMBOL PNL
sc.Subgraph[54][sc.Index]=currentSymbolPnL;
sc.Subgraph[55][sc.Index]=otherSymbolPnL;
Date Time Of Last Edit: 2026-02-11 22:02:59
imageSierra Other Symbol Position Data Error.png / V - Attached On 2026-02-11 21:07:53 UTC - Size: 4.32 KB - 36 views
[2026-02-13 21:16:45]
Gradient - Posts: 199
Can someone provide an update to this post.

Given that the PositionData is only being stored in a subgraph, it appears that there is an issue with the s_SCPositionData structure.

For example, the issue with erroneous PositionData.OpenProfitLoss has apparently existed for a while. The same issue presented here is evident in the following post:
[ACSIL] - Get current position data

In that post the PositionData.OpenProfitLoss appears incorrect as well.

If the same study is run on two charts with the exact same inputs then the outputs should be identical across each chart.

For example, if Study A computes the sum of pnl for Chart A and Chart B, then when applying Study A to Chart A and Chart B, the pnl should be identical.

There's no condition where there should be any deviation between the outputs. It's a simple summation of the Chart A and B applied to Chart A and B.

This, as I've shown, is not the case. If there was an issue in the logic then both charts would yield incorrect values, due to redundancy.

It's impossible for the logic to be flawed and the study work on one chart and not the other because the inputs are identical.
[2026-02-13 21:39:09]
User431178 - Posts: 855
Check the docs, PnL is not populated when you get other symbol position data.

Automated Trading From an Advanced Custom Study: sc.GetTradePositionForSymbolAndAccount()
[2026-02-14 02:05:26]
Gradient - Posts: 199
Thanks. Makes sense.

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

Login

Login Page - Create Account