SCSSierra Chart Study
ReviewsBlogAboutSupport
Sign InGet Started
Back to glossary
ACSIL & development

Auto-looping

The default ACSIL execution mode where Sierra Chart calls a study once per bar, walking from oldest to newest. Disable to handle the full chart in a single call (manual looping), useful for studies that compute aggregates across all bars.

What it is

Auto-looping is the default ACSIL execution mode for Sierra Chart custom studies. With auto-looping enabled, Sierra Chart calls your scsf_ function once per bar, walking from the oldest bar in the chart's lookback range up to the most recent bar. On each call, the study interface's bar index — sc.Index — points at the current bar, and you write your output to subgraphs at that index.

The alternative is manual looping (sometimes called "single-call" or "full-recalculation mode"), in which Sierra Chart calls the function once per chart pass and gives the study responsibility for iterating across bars itself. With manual looping you would write your own for loop from sc.UpdateStartIndex to sc.ArraySize, reading and writing bar arrays directly.

The choice between the two modes is declared in the SetDefaults block via sc.AutoLoop. Set it to 1 for auto-looping, or 0 for manual mode. The default is auto-looping.

Why it matters

Auto-looping is the right choice for most studies. It encapsulates the bar-walking logic, handles incremental updates efficiently (only re-computing the most recent bars on each tick after the chart is fully loaded), and makes the per-bar code straightforward to read: you write what should happen on this bar, and the platform handles the iteration.

Manual mode exists for studies that need to compute aggregates across the entire chart in a single pass, or that need a different iteration order than oldest-to-newest. A volume profile that sums every tick across the whole session, a study that needs to look forward as well as backward, or a study that integrates with external data sources on each pass are typical candidates for manual mode.

The performance characteristics differ too. Auto-looping is generally faster for routine per-bar computation because the platform skips already-computed bars on subsequent passes. Manual mode reprocesses the full window every call unless the study tracks its own incremental state.

How it's used in ACSIL code

In auto-looping mode, the runtime body of an scsf_ function looks like a straight-line computation:

sc.Subgraph[0][sc.Index] = sc.Close[sc.Index] - sc.Close[sc.Index - 1];

In manual mode, the same logic needs an explicit loop:

for (int i = sc.UpdateStartIndex; i < sc.ArraySize; ++i) {
  sc.Subgraph[0][i] = sc.Close[i] - sc.Close[i - 1];
}

The platform exposes sc.UpdateStartIndex so a manual-mode study only re-processes bars that need recomputation since the last call.

Common patterns / pitfalls

  • Default is auto-looping — if you don't set sc.AutoLoop, you are in auto-looping mode.
  • Don't mix paradigms — in auto-looping mode, never write your own loop across bars; the platform is already iterating. Doing so will compute the same operation O(N²) times and crater performance on long charts.
  • Use manual mode for cross-bar aggregates — a study that needs to know "what's the highest high across the whole chart right now" is cleaner in manual mode.
  • Edge handling at bar boundaries — sc.Index - 1 is invalid on the first bar. Always check sc.Index > 0 before reading the previous bar.
  • Tick-by-tick vs bar-close — auto-looping calls the function on every incoming tick for the current (forming) bar. If you only want the logic to fire on bar close, gate it with sc.GetBarHasClosedStatus.

Related SCS studies

Most SCS studies use auto-looping. Studies that produce per-bar overlays — Delta Candle Color, Single Print and Gap, CVD Filled Area — are natural fits. Studies that aggregate or scan across a full session may run in manual mode internally; the choice is opaque to users.

See also

ACSILscsf_ functionPersistent variables

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
SCS

Professional custom studies for Sierra Chart traders. Built for precision, designed to save time and protect your capital.

support@scstudies.comDiscord community

Products

  • Trade Manager
  • All Studies
  • Custom Studies

Company

  • About
  • Support & SAV
  • Terms of Service
  • Privacy Policy
  • Refund Policy

© 2026 SCS. All rights reserved.

Sierra Chart® is a registered trademark of Sierra Chart Engineering. SCS is independent and not affiliated with Sierra Chart.