Two candles can cover exactly the same price range yet finish with very different evidence of directional pressure. If your chart highlights every wide candle equally, it may hide the distinction between a close near the high and a late rejection. This Sierra Chart ACSIL tutorial builds a compact closed-bar diagnostic to make that distinction explicit.
What you’ll learn
- Measure the close within the completed candle range.
- Classify strong and weak close locations with symmetric thresholds.
- Implement a native ACSIL histogram with closed-bar gating.
- Install and validate the study using controlled examples.
Advanced Trading Tutorial | Sierra Chart ACSIL
Measure location, not direction alone
Close location is 100 times (Close minus Low) divided by (High minus Low). A value of 100 means the close equals the high, while zero means it equals the low. A value of 50 places the close at the midpoint. Unlike candle body size, this calculation does not use the open. It therefore answers a different question from whether the candle is bullish or bearish. A flat bar receives a neutral value of 50 because division by zero is undefined.

Figure: hypothetical candles with high 110, low 100 and open 105. Closing at 108 produces 80%; closing at 102 produces 20%.
Threshold design
The default upper threshold is 75 and the lower threshold is derived as 100 minus the upper threshold. Values strictly above 75 are green; values strictly below 25 are red. Equality is neutral. Keeping both thresholds linked avoids contradictory classifications. Increasing the upper threshold to 90 makes the condition more selective, while reducing it toward 50 highlights more bars. Neither choice is inherently superior. Choose a setting appropriate to the research question rather than optimizing it solely against historical returns.
Complete native indicator
#include "sierrachart.h"
SCDLLName("PatternSmart Close Location")
SCSFExport scsf_PSCloseLocation(SCStudyInterfaceRef sc)
{
SCSubgraphRef Score = sc.Subgraph[0];
SCSubgraphRef Upper = sc.Subgraph[1];
SCSubgraphRef Lower = sc.Subgraph[2];
SCInputRef Threshold = sc.Input[0];
if (sc.SetDefaults)
{
sc.GraphName = "PS Closed Bar Close Location";
sc.AutoLoop = 1;
sc.GraphRegion = 1;
Score.Name = "Close Location Percent";
Score.DrawStyle = DRAWSTYLE_BAR;
Score.PrimaryColor = RGB(100,100,100);
Score.DrawZeros = true;
Upper.Name = "Upper Threshold";
Lower.Name = "Lower Threshold";
Upper.DrawStyle = Lower.DrawStyle = DRAWSTYLE_LINE;
Upper.PrimaryColor = RGB(30,135,100);
Lower.PrimaryColor = RGB(190,65,65);
Threshold.Name = "Upper Threshold Percent";
Threshold.SetFloat(75.0f);
Threshold.SetFloatLimits(50.0f,100.0f);
return;
}
const int i = sc.Index;
const float t = Threshold.GetFloat();
Upper[i] = t;
Lower[i] = 100.0f-t;
// Never publish a provisional score for the forming bar.
Score[i] = 0;
if (sc.GetBarHasClosedStatus() != BHCS_BAR_HAS_CLOSED)
return;
const float range = sc.High[i]-sc.Low[i];
// A flat bar has no directional close location.
const float value = range > 0
? 100.0f*(sc.Close[i]-sc.Low[i])/range : 50.0f;
Score[i] = value;
Score.DataColor[i] = value > t ? RGB(30,135,100)
: value < 100.0f-t ? RGB(190,65,65)
: RGB(100,100,100);
}
Implementation details
AutoLoop lets Sierra Chart call the study for each relevant bar. Subgraphs store the score and two reference lines. DataColor assigns the histogram color independently for each index. The study checks bar closure before computing the score, and does not access future bars. The forming bar is represented by a zero-height placeholder, not a valid bearish observation. A genuine zero score also has zero height; inspect the chart values and the bar's completion status to distinguish them. The last chart bar is normally considered unclosed until another bar exists, even when the market has stopped trading. This is a deliberate latency tradeoff.
Installation and testing
Save the code as a C++ source file in the Sierra Chart ACS_Source directory. Open Analysis, Build Custom Studies DLL, select the source file and use the available build command. After a successful build, open Analysis, Studies, Add Custom Study and select PS Closed Bar Close Location. Apply it to a chart with standard OHLC bars. The study uses the chart's own price series and session settings. The source has been written for ACSIL but has not been compiled or executed in Sierra Chart for this article.
Start with a manually inspected candle whose high is 110 and low is 100. A close of 108 should yield 80 and green; a close of 102 should yield 20 and red. A close of 107.5 should yield 75 and neutral. A flat candle at 100 should yield 50. During replay, watch the active candle remain unclassified until the next bar begins. Compare historical values after reloading the chart using the same data and settings. A feed correction or a change in chart construction can alter historical OHLC values and therefore the score; that is not future-data lookahead.
Interpretation and limitations
A high score describes where the bar finished, not the probability that the next bar will rise. A narrow bar can score 100 just as a wide bar can. Consider range or volume context separately when studying whether the observation is meaningful. Gap behavior, synthetic bars and illiquid markets may change the interpretation. The histogram is a diagnostic rather than an entry system, and does not submit orders or estimate transaction costs. For custom range filters, alerts or integration with other studies, explore Custom Sierra Chart indicator Development Services.
Risk disclosure: Educational material only. Trading involves risk of loss; hypothetical examples are not performance evidence. Validate independently before relying on any indicator.