Sierra Chart Bid/Ask Delta Context: Closed-Bar Aggressor-Volume Agreement in ACSIL C++
Beginner Trading Tutorial | Sierra Chart | Order-flow data interpretation | ACSIL C++
One common mistake in trading analysis is treating a green price candle as proof that buyers controlled every trade. Price movement and the direction of classified traded volume are related, but they are not the same measurement. Sierra Chart provides separate Ask Volume and Bid Volume arrays that let us investigate how aggressively traded volume lined up with a completed candle's price direction.
This tutorial creates a complete custom study for Sierra Chart using the Advanced Custom Study Interface and Language (ACSIL). It computes signed Bid/Ask Delta Percent, draws it in a separate indicator region, and places colored markers when price and delta agree—or disagree—beyond a configurable threshold. It does not place orders and is not a forecast of the next candle.
The question behind a price candle
Suppose one completed bar closes above its open. If the Ask-side classified traded volume was 780 and the Bid-side volume was 520, the difference was +260. Dividing by the total 1,300 gives +20.0%. This means the bar had a positive classified delta, not that all orders were buys. A down candle with Ask Volume 420 and Bid Volume 780 produces -360 / 1,200 = -30.0%, representing agreement between the negative delta and the candle's downward body.
Now compare an up candle with Ask Volume 490 and Bid Volume 810. Its volume delta is -320 / 1,300 ≈ -24.6%. Price finished higher, yet more traded volume was classified on the Bid side. The study marks that situation as a price/delta mismatch. It may be interesting context, but it does not prove hidden absorption or a coming reversal.

What Ask Volume and Bid Volume actually measure
Sierra Chart documents sc.AskVolume[] as traded volume classified at the Ask price or higher and sc.BidVolume[] as traded volume classified at the Bid price or lower; certain trades between quoted prices may be assigned according to uptick/downtick rules. These arrays are not the number of resting buy or sell limit orders on the DOM. Consequently, the subtraction AskVolume − BidVolume is a bar-level classification-based delta proxy, not a direct count of individual institutional decisions.
The key data prerequisite is accurate intraday trades with reliable Bid/Ask classification. Sierra Chart documentation notes that tick-by-tick storage and suitable intraday data are necessary for accurate Bid/Ask-volume calculations and that source feeds or reconstructed bars can differ. Historical Daily bars or arbitrary imported OHLC files may not contain sufficient classification detail. When the arrays are empty or unreliable, treat the output as unavailable rather than a legitimate zero-delta reading.
Four checks, one interpretable signal
The program applies four questions in sequence. First, has the bar completed? Second, is the sum of classified Ask and Bid volume at least the configured minimum (500 units by default)? Third, is the absolute delta at least 15%? Finally, does delta direction agree with price direction? A green candle and delta at or above +15% produce a bullish agreement point. A red candle and delta at or below -15% produce a bearish agreement point. An opposite-sign strong delta produces an amber mismatch point. Weak delta, doji candles, low-volume data, and unclosed bars produce no agreement marker.

Configurable defaults and their trade-offs
| Input | Default | Interpretation |
|---|---|---|
| Minimum Absolute Delta Percent | 15.0 | Higher values demand a stronger imbalance, yield fewer markers, and can omit smaller but meaningful events. |
| Minimum Ask + Bid Traded Volume | 500 | Suppresses thin or missing classifications. Choose a suitable value for the instrument, bar period, and data feed. |
There is no universal right threshold. A 500-contract requirement may be plausible for one futures chart but entirely wrong for a thin symbol or a small intraday bar. Instead of optimizing thresholds to maximize historical wins, start with a fixed parameter set, write down why it was chosen, and compare distributions across multiple sessions. The current version intentionally uses only two inputs, allowing a beginner to see exactly why a marker appears.
Complete Sierra Chart ACSIL C++ source
Save the following code as PS_SC_DeltaContext.cpp in Sierra Chart's ACS_Source directory. It is a self-contained study: SCDLLName declares the library; scsf_PatternSmartDeltaContext is the exported study function; sc.AutoLoop = 1 processes bar indices; and seven sc.Subgraph arrays represent histogram, event markers, thresholds and zero reference. The English and Chinese editions include the identical code listing.
// PatternSmart Sierra Chart Closed-Bar Bid/Ask Delta Context
// Save as PS_SC_DeltaContext.cpp in SierraChart/ACS_Source
#include "sierrachart.h"
SCDLLName("PatternSmart Delta Context")
SCSFExport scsf_PatternSmartDeltaContext(SCStudyInterfaceRef sc)
{
SCSubgraphRef DeltaPercent = sc.Subgraph[0];
SCSubgraphRef BullAgreement = sc.Subgraph[1];
SCSubgraphRef BearAgreement = sc.Subgraph[2];
SCSubgraphRef PriceDeltaMismatch = sc.Subgraph[3];
SCSubgraphRef PositiveThreshold = sc.Subgraph[4];
SCSubgraphRef NegativeThreshold = sc.Subgraph[5];
SCSubgraphRef ZeroLine = sc.Subgraph[6];
SCInputRef MinAbsDeltaPercent = sc.Input[0];
SCInputRef MinClassifiedVolume = sc.Input[1];
if (sc.SetDefaults)
{
sc.GraphName = "PS Bid/Ask Delta Context (Closed Bars)";
sc.StudyDescription = "Classified trade-volume delta and price agreement; study only, no orders.";
sc.AutoLoop = 1;
sc.GraphRegion = 1;
sc.ValueFormat = 2;
DeltaPercent.Name = "Ask Minus Bid / Classified Volume (%)";
DeltaPercent.DrawStyle = DRAWSTYLE_BAR;
DeltaPercent.PrimaryColor = RGB(36, 97, 191);
DeltaPercent.LineWidth = 5;
DeltaPercent.DrawZeros = 0;
BullAgreement.Name = "Bullish Price/Delta Agreement";
BullAgreement.DrawStyle = DRAWSTYLE_POINT;
BullAgreement.PrimaryColor = RGB(21, 142, 105);
BullAgreement.LineWidth = 7;
BullAgreement.DrawZeros = 0;
BearAgreement.Name = "Bearish Price/Delta Agreement";
BearAgreement.DrawStyle = DRAWSTYLE_POINT;
BearAgreement.PrimaryColor = RGB(191, 72, 77);
BearAgreement.LineWidth = 7;
BearAgreement.DrawZeros = 0;
PriceDeltaMismatch.Name = "Price/Delta Mismatch (Context Only)";
PriceDeltaMismatch.DrawStyle = DRAWSTYLE_POINT;
PriceDeltaMismatch.PrimaryColor = RGB(170, 123, 37);
PriceDeltaMismatch.LineWidth = 5;
PriceDeltaMismatch.DrawZeros = 0;
PositiveThreshold.Name = "+Delta Threshold (%)";
PositiveThreshold.DrawStyle = DRAWSTYLE_LINE;
PositiveThreshold.PrimaryColor = RGB(21, 142, 105);
PositiveThreshold.LineWidth = 1;
NegativeThreshold.Name = "-Delta Threshold (%)";
NegativeThreshold.DrawStyle = DRAWSTYLE_LINE;
NegativeThreshold.PrimaryColor = RGB(191, 72, 77);
NegativeThreshold.LineWidth = 1;
ZeroLine.Name = "Zero Delta";
ZeroLine.DrawStyle = DRAWSTYLE_LINE;
ZeroLine.PrimaryColor = RGB(110, 125, 140);
ZeroLine.LineWidth = 1;
MinAbsDeltaPercent.Name = "Minimum Absolute Delta Percent";
MinAbsDeltaPercent.SetFloat(15.0f);
MinAbsDeltaPercent.SetFloatLimits(0.1f, 100.0f);
MinClassifiedVolume.Name = "Minimum Ask + Bid Traded Volume";
MinClassifiedVolume.SetInt(500);
MinClassifiedVolume.SetIntLimits(1, 100000000);
return;
}
const int i = sc.Index;
const float threshold = MinAbsDeltaPercent.GetFloat();
PositiveThreshold[i] = threshold;
NegativeThreshold[i] = -threshold;
ZeroLine[i] = 0.0f;
// Reset all outputs; the newest incomplete bar remains blank.
DeltaPercent[i] = 0.0f;
BullAgreement[i] = 0.0f;
BearAgreement[i] = 0.0f;
PriceDeltaMismatch[i] = 0.0f;
if (sc.GetBarHasClosedStatus(i) != BHCS_BAR_HAS_CLOSED)
return;
const float ask = (float)sc.AskVolume[i];
const float bid = (float)sc.BidVolume[i];
const float classifiedVolume = ask + bid;
// Missing or sparse classified volume cannot make a valid signal.
if (classifiedVolume <= 0.0f
|| classifiedVolume < MinClassifiedVolume.GetInt())
return;
const float deltaPct = 100.0f * (ask - bid) / classifiedVolume;
DeltaPercent[i] = deltaPct;
DeltaPercent.DataColor[i] = (deltaPct >= 0.0f)
? RGB(21, 142, 105) : RGB(191, 72, 77);
const bool upBar = sc.Close[i] > sc.Open[i];
const bool downBar = sc.Close[i] < sc.Open[i];
const bool posStrong = deltaPct >= threshold;
const bool negStrong = deltaPct <= -threshold;
if (upBar && posStrong)
BullAgreement[i] = deltaPct;
else if (downBar && negStrong)
BearAgreement[i] = deltaPct;
else if ((upBar && negStrong) || (downBar && posStrong))
PriceDeltaMismatch[i] = deltaPct;
// An unchanged open-to-close bar has no directional agreement signal.
// This indicator never submits a trading order.
}
Why closed-bar logic matters
Bid/Ask delta fluctuates while the newest bar is still accumulating trades, as does its close-to-open direction. The study explicitly calls sc.GetBarHasClosedStatus(i) and writes no new delta or agreement point until that bar is closed. It also resets outputs for the still-open bar rather than allowing provisional historical-looking dots. Depending on bar type, a new bar may be needed before the platform identifies the previous bar as closed; this is intentional.
DeltaPercent.DataColor[i] makes positive and negative histogram bars distinguishable. Separate subgraphs add green agreement points, red agreement points, and amber mismatch points at the same delta percentage level; their interpretation is categorical, not trading execution. The +15% and -15% reference lines are fixed for the chosen input setting.
Installation and first-run validation
- Confirm your chart is an intraday instrument with suitable tick-by-tick data and usable Bid/Ask trade classification. Check Sierra Chart's Intraday Data Storage Time Unit and data service settings for the symbol.
- Open Analysis → Build Custom Studies DLL, place the source file in
ACS_Source, and compile with a supported compiler / Sierra Chart remote build method. Compilation was not performed in this environment. - Add the new custom study to a chart via Analysis → Studies, select the chart region below price, and begin with a 15% delta gate and 500 classified-volume minimum.
- For three selected completed bars, use Sierra Chart's chart data to verify Ask Volume and Bid Volume, recompute the percentage by hand, and inspect the green/red/amber marker logic.
- Observe the forming rightmost bar: the indicator should wait for closure. Compare results after a historical reload to detect data-reconstruction issues.
What can go wrong—and what to test
Data-quality failure: If your feed does not preserve Bid/Ask trade classification, a valid-looking price chart is insufficient. The default minimum-volume gate avoids division by zero or trivial tiny samples, but it cannot prove a feed is accurate.
Direction versus causation: A green candle with negative delta could arise from passive liquidity interactions, trade classification quirks, or microstructure effects. The study labels it as disagreement, not proven absorption. Likewise, price and delta agreement is not a reliable profit signal in isolation.
Aggregation and sessions: Bid/Ask sums change with aggregation, chart construction, historical tick storage, and trading sessions. Do not compare raw delta percentages across feeds without checking that classification and underlying data rules are compatible.
Research checklist: Manually reproduce the 780/520, 490/810, and 420/780 examples. Then record at least 30 real closed bars across active and quiet sessions, note sign agreement, absolute delta, available trade volume, spreads, and subsequent price behavior. Verify false positives and do not invent backtested performance from illustrative cases.
Interested in extending this free study with alerts, data-quality diagnostics, instrument-specific thresholds, or additional depth-of-market context? You can discuss a tailored version through Custom Trading Software Development Services.
Educational research tool, not investment advice or a recommendation to execute orders. Confirm C++ build compatibility, feed quality, data permissions and risk controls in your own Sierra Chart environment before using any signal.