Login Page - Create Account

Support Board


Date/Time: Tue, 15 Apr 2025 13:50:09 +0000



[Programming Help] - I have a programming question(TPO-Profile Chart)

View Count: 76

[2025-04-07 08:51:26]
User134797 - Posts: 55
Good morning,

I have a programming question: I am using the following study chart “TPO Profile Chart”. This chart has a tab labeled “Subgraphs” with subgraphs named SG1, SG2, SG3, SG4, etc. I want to read all these SG’s via a script. I have created the script, but I am only able to read SG1, SG2, SG3, and SG4. Do you perhaps know why it is not possible to read the rest of the SG’s?

Thanks in advance for your support.
[2025-04-07 14:57:26]
John - SC Support - Posts: 39274
You should still be able to get the data from the other subgraphs, although most of them will be zeros, as many of the other subgraphs are only for coloring/width options and do not actually hold any data.

How are you accessing the subgraph data?
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2025-04-07 15:27:02]
User134797 - Posts: 55
This is the script.

#include <windows.h>
#include "sierrachart.h"
SCDLLName("TPO Exporter – Uitgebreid")

SCSFExport scsf_TPOExport(SCStudyInterfaceRef sc)
{
SCInputRef StartExport = sc.Input[0];
SCInputRef AantalDagen = sc.Input[1];
SCInputRef TPOStudyID = sc.Input[2];

if (sc.SetDefaults)
{
sc.GraphName = "TPO Exporter – Uitgebreid";
sc.AutoLoop = 0;

StartExport.Name = "Start Export";
StartExport.SetYesNo(false);

AantalDagen.Name = "Aantal dagen om te exporteren";
AantalDagen.SetInt(3);
AantalDagen.SetIntLimits(1, 30);

TPOStudyID.Name = "Study ID van TPO Chart";
TPOStudyID.SetStudyID(3); // pas aan indien anders

return;
}

if (!StartExport.GetYesNo())
return;

StartExport.SetYesNo(false);

// 📅 Bestandsnaam per dag
SCDateTime vandaag = sc.CurrentSystemDateTime.GetDate();
char datumLabel[11];
snprintf(datumLabel, sizeof(datumLabel), "%04d-%02d-%02d",
vandaag.GetYear(), vandaag.GetMonth(), vandaag.GetDay());

SCString bestandPad = sc.DataFilesFolder();
bestandPad += "\\TPO_";
bestandPad += datumLabel;
bestandPad += ".csv";

FILE* bestand = fopen(bestandPad.GetChars(), "w");
if (!bestand)
{
SCString foutmelding = "❌ Kan bestand niet openen: ";
foutmelding += bestandPad;
sc.AddMessageToLog(foutmelding, 1);
return;
}

// ✅ Header met alles
fprintf(bestand, "Datum,Open,High,Low,Last,POC,VAH,VAL,POC_EXT,OpenMarker,LastT,InBalance,IBR1,OpenRange,PoorHL\n");

int tpoID = TPOStudyID.GetStudyID();

// ✅ Standaardvelden
SCFloatArray OpenArray, HighArray, LowArray, LastArray;
SCFloatArray VALArray, POCArray, VAHArray;

sc.GetStudyArrayUsingID(tpoID, 0, OpenArray);
sc.GetStudyArrayUsingID(tpoID, 1, HighArray);
sc.GetStudyArrayUsingID(tpoID, 2, LowArray);
sc.GetStudyArrayUsingID(tpoID, 3, LastArray);
sc.GetStudyArrayUsingID(tpoID, 15, VALArray);
sc.GetStudyArrayUsingID(tpoID, 16, POCArray);
sc.GetStudyArrayUsingID(tpoID, 17, VAHArray);

// ✅ Extra SG’s
SCFloatArray POC_Ext, OpenMarker, LastT, InBalance, IBR1, OpenRange, PoorHL;
sc.GetStudyArrayUsingID(tpoID, 14, POC_Ext);
sc.GetStudyArrayUsingID(tpoID, 18, OpenMarker);
sc.GetStudyArrayUsingID(tpoID, 20, LastT);
sc.GetStudyArrayUsingID(tpoID, 21, InBalance);
sc.GetStudyArrayUsingID(tpoID, 22, IBR1);
sc.GetStudyArrayUsingID(tpoID, 25, OpenRange);
sc.GetStudyArrayUsingID(tpoID, 34, PoorHL);

SCDateTime vorigeDatum = 0;
int geschreven = 0;

for (int i = sc.ArraySize - 1; i >= 0 && geschreven < AantalDagen.GetInt(); --i)
{
SCDateTime tijd = sc.BaseDateTimeIn.GetDate();
if (tijd == vorigeDatum)
continue;

vorigeDatum = tijd;

if (OpenArray == 0 && HighArray == 0 && LowArray == 0 && LastArray == 0)
continue;

char datumStr[11];
snprintf(datumStr, sizeof(datumStr), "%04d-%02d-%02d",
tijd.GetYear(), tijd.GetMonth(), tijd.GetDay());

fprintf(bestand, "%s,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f\n",
datumStr,
OpenArray, HighArray, LowArray, LastArray,
POCArray, VAHArray, VALArray,
POC_Ext, OpenMarker, LastT, InBalance, IBR1, OpenRange, PoorHL);

++geschreven;
}

fclose(bestand);

SCString klaar = "✅ Uitgebreide TPO-export voltooid: ";
klaar += bestandPad;
sc.AddMessageToLog(klaar, 0);
}

[2025-04-07 23:29:08]
LudaTrades - Posts: 30
Your Open, High, Low, and Last subgraph indexes are correct and 0 based, but the rest do not seem to be, and you are grabbing color arrays and extension line styling anyway.

If you want the value area values, point of control, etc, try using sc.GetStudyProfileInformation.

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

Login

Login Page - Create Account