sc.Subgraph
The output channel of a Sierra Chart study — a plotted series accessible as `sc.Subgraph[index][bar]`. Studies can expose up to 256 subgraphs for lines, points, bars, or text overlays.
What it is
A subgraph is the output channel of a Sierra Chart study. Every value your study wants to display on the chart — a line, a histogram bar, a colored dot, a text label — is written into a subgraph. The study interface exposes them as an array: sc.Subgraph[0], sc.Subgraph[1], and so on, up to a maximum of 256 subgraphs per study.
Each subgraph is itself a per-bar array. sc.Subgraph[0][bar_index] is the value of the first subgraph at that bar. When Sierra Chart renders the chart, it walks the subgraph arrays and plots them according to each subgraph's configured draw style — line, histogram, point, bar, text, etc.
Subgraphs are also where a study declares its visual identity. In the SetDefaults block of a study, you configure each subgraph's name (sc.Subgraph[i].Name), color, draw style (sc.Subgraph[i].DrawStyle), line width, and so on. These settings become editable from the study's settings dialog at runtime, so users can recolor or hide a subgraph without touching code.
Why it matters
Subgraphs are the bridge between your computation and what the trader sees. A study with no subgraphs is invisible — it can still execute logic and place orders, but it has no visual output. Most studies define between one and a dozen subgraphs.
The subgraph is also the natural unit for cross-study referencing. Other studies can read your subgraph values via the study reference system, and chartbook layouts can chain multiple studies together by piping one study's subgraph into the next. This is how Sierra Chart composes building-block studies into more complex toolkits.
Beyond plotting, subgraphs carry a few useful side slots. sc.Subgraph[i].Arrays[j] provides extra per-bar floating-point arrays you can use as scratch space without allocating your own storage. This is a common pattern when you need to remember intermediate values from bar to bar.
How it's used in ACSIL code
A typical pattern: in SetDefaults, you assign sc.Subgraph[0].Name = "MyValue", set its DrawStyle and PrimaryColor, and declare how many subgraphs the study will use. In the runtime body, on each bar, you compute a value and write sc.Subgraph[0][sc.Index] = computed_value. Sierra Chart picks that up on the next chart redraw and plots it.
For non-numeric output — text labels, drawing tools, custom GDI rendering — subgraphs still play a role as the anchor for color and visibility settings, even when the actual rendering goes through other ACSIL APIs.
Common patterns / pitfalls
- Declare upfront — set every subgraph's name and draw style in
SetDefaults. Adding subgraphs later or changing names breaks chartbook persistence. - Index 0 vs 1 — subgraph indices start at 0. The convention in many built-in studies is to use sequential indices and document them with comments.
- Don't exceed 256 — the platform-imposed limit. Most studies use far fewer.
- Use
Arraysfor state — when you need per-bar scratch space,sc.Subgraph[i].Arrays[j]is cheaper thansc.GetPersistent*. - DrawStyle matters at scale — line, histogram, and dot draw styles have very different rendering costs on long charts. Pick the lightest style that conveys the signal.
Related SCS studies
SCS studies use subgraphs everywhere — Trade Manager surfaces its position state through subgraphs that the ACS buttons read, the CVD Filled Area study uses multiple subgraphs to render its line and fill independently, and the Single Print and Gap study uses subgraphs to mark each untested level on the chart.
See also
About the acsil & development category
Sierra Chart's Advanced Custom Study Interface and Language — the C++ surface SCS studies are built on.
Browse the full glossary