Login Page - Create Account

Support Board


Date/Time: Sat, 15 Nov 2025 14:30:07 +0000



Exporting Fib tools Data

View Count: 1200

[2017-03-04 17:39:55]
BenjaminR - Posts: 179
I've tried using the spreadsheet study export Fibonacci level data, but doesn't seem it will export data from the Price Retracement tool.

Is there study or tool that can do this in Sierra Chart?

The idea is to find Fibonacci clusters using several time frames, then use that data to manually mark zones on a primary chart.

Thank you,

Ben
Date Time Of Last Edit: 2017-03-04 17:40:26
[2017-03-05 20:35:36]
Sierra Chart Engineering - Posts: 104368
You will need to use ACSIL for this:
Advanced Custom Study Interface and Language (ACSIL)



This is the particular function to access the data:
Using Drawing Tools From an Advanced Custom Study: sc.GetUserDrawnChartDrawing()
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2025-09-16 19:09:56]
User676363 - Posts: 87
Here's a code example for exporting the risk/reward tool to the message log.
Should be relatively easy to modify it to work with the other tools especially with the use of an LLM to assist.

It produces a log entry like this for each line and some summary info at the end for all the entries.

2025-09-16 14:51:08.660 | Chart: NQZ25_FUT_CME [CBV][M] 15 Sec #4 | Study: Log Risk/Reward Drawings | Reward/Risk Tool | Stop=24635.00 (6 ticks)@2025-09-16 04:45:30 | Entry=24636.50@2025-09-16 04:46:30 | Target=24644.75 (33 ticks)@2025-09-16 04:48:30 | R=+5.50 | Duration=2.0 min | Line=-395
2025-09-16 14:51:08.660 | Chart: NQZ25_FUT_CME [CBV][M] 15 Sec #4 | Study: Log Risk/Reward Drawings | Reward/Risk Tool | Stop=24638.75 (16 ticks)@2025-09-16 05:15:30 | Entry=24634.75@2025-09-16 05:16:30 | Target=24620.50 (57 ticks)@2025-09-16 05:30:00 | R=+3.56 | Duration=13.5 min | Line=-397
2025-09-16 14:51:08.660 | Chart: NQZ25_FUT_CME [CBV][M] 15 Sec #4 | Study: Log Risk/Reward Drawings | Reward/Risk Tool | Stop=24532.00 (11 ticks)@2025-09-16 14:42:15 | Entry=24534.75@2025-09-16 14:44:30 | Target=24544.75 (40 ticks)@2025-09-16 14:50:30 | R=+3.64 | Duration=6.0 min | Line=-415
2025-09-16 14:51:08.660 | Chart: NQZ25_FUT_CME [CBV][M] 15 Sec #4 | Study: Log Risk/Reward Drawings | Session Totals | Total Duration=21.5 min | Total R=12.70 | Max Risk=16 ticks | Max Profit=57 ticks


Save the file as LogRiskReward.cpp or whatever you like and then compile it and load it. Set the Run to Yes and apply the study. It will run once, for all the RR tools on the chart and set itself to No. If you later add more, you can just open the study properties and select yes and it will export the new data. If you want your duration to be correct, you will need to ensure that the target or the stop is actually where you closed the trade and the entry will need to be adjusted to the candle where it was executed. If you want your journal to show a losing trade, you need to make sure the stop of the RR tool is the last point (in terms of date and time on the time axis) - just move it to where you were stopped out and put the target to a point before that stop in terms of time and the log above will show a -1 R for that line and it will set the trade duration.

#include "sierrachart.h"

SCDLLName("LogRiskReward")

SCSFExport scsf_LogRiskRewardDrawings(SCStudyInterfaceRef sc)
{
// === Inputs ===
SCInputRef Input_Run = sc.Input[0];

if (sc.SetDefaults)
{
sc.GraphName = "Log Risk/Reward Drawings";
sc.AutoLoop = 0;
sc.GraphRegion = 0; // use primary chart region

Input_Run.Name = "Run Reward/Risk Logging";
Input_Run.SetYesNo(0);

return;
}

// Only run if user enabled input and hasn't run yet
if (Input_Run.GetYesNo() == 0)
return;

int DrawingIndex = 0;
s_UseTool Tool;

double totalR = 0.0;
double totalDurationMinutes = 0.0;
double maxRiskTicks = 0.0;
double maxProfitTicks = 0.0;

while (sc.GetUserDrawnChartDrawing(sc.ChartNumber, DRAWING_REWARD_RISK, Tool, DrawingIndex) != 0)
{
double StopPrice = Tool.BeginValue;
double EntryPrice = Tool.EndValue;
double TargetPrice = Tool.ThirdValue;

SCDateTime StopDT = Tool.BeginDateTime;
SCDateTime EntryDT = Tool.EndDateTime;
SCDateTime TargetDT = Tool.ThirdDateTime;

// Determine which point came last in time (to identify win/loss)
SCDateTime LastDT;
double LastPrice;
if (StopDT > TargetDT) {
LastDT = StopDT;
LastPrice = StopPrice;
} else {
LastDT = TargetDT;
LastPrice = TargetPrice;
}

double RiskTicks = fabs(EntryPrice - StopPrice) / sc.TickSize;
double RewardTicks = fabs(TargetPrice - EntryPrice) / sc.TickSize;

// Calculate R for the trade (+R for win, -R for loss)
double tradeR = (LastPrice == TargetPrice) ? (RewardTicks / RiskTicks) : (-RiskTicks / RiskTicks);

// Calculate duration from entry to last point
double durationMinutes = (LastDT.GetAsDouble() - EntryDT.GetAsDouble()) * 24.0 * 60.0;

// Update session totals
totalR += tradeR;
totalDurationMinutes += durationMinutes;
maxRiskTicks = max(maxRiskTicks, RiskTicks);
if (tradeR > 0) // only consider winning trades for max profit
maxProfitTicks = max(maxProfitTicks, RewardTicks);


// Format times
SCString StopTimeStr = sc.FormatDateTime(StopDT);
SCString EntryTimeStr = sc.FormatDateTime(EntryDT);
SCString TargetTimeStr = sc.FormatDateTime(TargetDT);

// Prepare log message
SCString Msg;
Msg.Format(
"Reward/Risk Tool | Stop=%.2f (%d ticks)@%s | Entry=%.2f@%s | Target=%.2f (%d ticks)@%s | R=%+.2f | Duration=%.1f min | Line=%d",
StopPrice, (int)RiskTicks, StopTimeStr.GetChars(),
EntryPrice, EntryTimeStr.GetChars(),
TargetPrice, (int)RewardTicks, TargetTimeStr.GetChars(),
tradeR,
durationMinutes,
Tool.LineNumber
);
sc.AddMessageToLog(Msg, 0);

DrawingIndex++;
}

// Log session totals
SCString TotalMsg;
TotalMsg.Format(
"Session Totals | Total Duration=%.1f min | Total R=%.2f | Max Risk=%d ticks | Max Profit=%d ticks",
totalDurationMinutes,
totalR,
(int)maxRiskTicks,
(int)maxProfitTicks
);
sc.AddMessageToLog(TotalMsg, 0);

// Mark as done
Input_Run.SetYesNo(0);
}

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

Login

Login Page - Create Account