Login Page - Create Account

Support Board


Date/Time: Mon, 15 Dec 2025 05:02:04 +0000



[Programming Help] - Trade Statistics in ACSIL

View Count: 1609

[2024-12-15 18:01:20]
User081362 - Posts: 8
Hello,

I can't seem to find a function to retrieve the total trades on an account. I found one that retrieves them for the day but I need total of all time. I currently have a code built that exports to a csv but it is over-complicated for what I need. Objective is to get the win rate for my bot. Any help is appreciated.
[2024-12-16 06:57:25]
Sierra_Chart Engineering - Posts: 21842
You need to set the chart to load the order fills required.:
Chart Settings: Trading

And then use this function:
ACSIL Interface Members - Functions: sc.GetTradeStatisticsForSymbolV2()
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, use the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2024-12-16 06:58:14
[2025-12-02 18:03:14]
jsandlan - Posts: 85
When I have Trade and Current Quote Symbol (Action) set to a different symbol than the current chart and Use As Trade Only Symbol set to yes in Chart Settings > Symbol the study below only returns trade stats for the Trade Only symbol.

I’ve discovered that the trade statistics returned by ACSIL are not including all trades across all symbols. Is there a way to retrieve trade stats for all symbols, not just the chart symbol or the trade-only symbol?

Here is the original implementation that returns only trades for the ticker the chart is set to trade from:


SCDLLName("TradeLocker")

SCSFExport scsf_TradeLocker(SCStudyInterfaceRef sc)
{
const int MaxTrades = 4;

static int LastTradingDay = -1;
static int TradesToday = 0;

if (sc.SetDefaults)
{
sc.GraphName = "TradeLocker";
sc.AutoLoop = 0;
sc.GraphRegion = 0; // ✅ Default to Chart Region 1
return;
}

int CurrentTradingDay = 0;
sc.GetTradingDayDate(CurrentTradingDay);

// Reset trade count at start of a new day/session
if (LastTradingDay != CurrentTradingDay)
{
LastTradingDay = CurrentTradingDay;
TradesToday = 0;
sc.SetTradingLockState(0);

SCString resetMsg;
resetMsg.Format("New trading day detected: %d. Lock reset.", CurrentTradingDay);
sc.AddMessageToLog(resetMsg, 0);
}

// Count completed trades since session start
int completedTrades = sc.GetFlatToFlatTradeListSize();
if (completedTrades > TradesToday)
TradesToday = completedTrades;

s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);

SCString msg;
msg.Format("Completed Trades Today: %d / %d, Position Quantity: %.2f",
TradesToday, MaxTrades, PositionData.PositionQuantity);
sc.AddMessageToLog(msg, 0);

// Lock/unlock logic
if (TradesToday >= MaxTrades && PositionData.PositionQuantity == 0)
sc.SetTradingLockState(1);
else
sc.SetTradingLockState(0);
}

Date Time Of Last Edit: 2025-12-02 18:26:29

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

Login

Login Page - Create Account