Beginner Trading Tutorial — Confirmed Prior Range Overlap in Sierra Chart

Two candles can have the same high-to-low distance while occupying very different price areas. A bar that remains entirely inside the previous range describes a different geometry from one that trades beyond it. This tutorial develops an ACSIL indicator to quantify that distinction using the percentage of the current completed bar's range that intersects the immediately preceding bar's range. It is a simple project for learning array access, subgraphs, manual looping and the treatment of unavailable observations in Sierra Chart. The result describes price geometry, not the direction or probability of the next move.

Define the intersection

Represent each bar by its low and high. Find the smaller of the two highs and the larger of the two lows. Subtract the latter from the former and clamp negative results to zero. This gives the length of the shared price interval. Divide by the current bar's high minus low and multiply by 100. A valid result falls between zero and 100 percent. The denominator is deliberately the current range, not the prior range or the union of both ranges. Consequently, the statistic answers a specific question: what fraction of the current price interval lies inside the preceding price interval?

Confirmed Prior Range Overlap Indicator
Three independent hypothetical cases use the same previous range of 100–110. Current ranges 102–108, 106–114 and 112–116 overlap by 100%, 50% and 0%, respectively. Green marks the shared interval, red marks the portion outside it.

Calculate the examples

Case A has a prior low of 100 and high of 110, with a current low of 102 and high of 108. The shared interval is 102–108 and its length is six. The current range is also six, giving 100%. Case B uses the same preceding range, but the current low is 106 and high is 114. The shared interval is 106–110, a length of four. Dividing by eight gives 50%. Case C has a current range of 112–116. There is no shared interval, so the ratio is 0%. These are separate examples, not consecutive observations.

Consider a fourth case where the current range is 95–115. It contains the entire preceding interval, yet the overlap ratio is only 50% because ten of its twenty price units lie inside the preceding interval. This illustrates why dividing by the prior range would answer a different question. When two intervals merely touch at one price, their intersection has zero length. A current bar with equal high and low has an undefined denominator and is marked unavailable instead of assigned an artificial percentage.

Complete ACSIL source code

#include "sierrachart.h"

SCDLLName("PatternSmart Range Overlap")

SCSFExport scsf_ConfirmedPriorRangeOverlap(SCStudyInterfaceRef sc)
{
    SCSubgraphRef Overlap = sc.Subgraph[0];
    SCSubgraphRef Valid = sc.Subgraph[1];

    if (sc.SetDefaults)
    {
        sc.GraphName = "Confirmed Prior Range Overlap";
        sc.StudyDescription = "Current range overlap with prior bar.";
        sc.AutoLoop = 0;
        sc.GraphRegion = 1;
        sc.ValueFormat = 2;

        Overlap.Name = "Overlap Percent";
        Overlap.DrawStyle = DRAWSTYLE_BAR;
        Overlap.PrimaryColor = RGB(45, 105, 190);
        Overlap.DrawZeros = false;

        // Hidden validity flag distinguishes zero overlap
        // from unavailable observations.
        Valid.Name = "Valid";
        Valid.DrawStyle = DRAWSTYLE_IGNORE;
        return;
    }

    // Revisit the previous bar after a new bar appears.
    int start = sc.UpdateStartIndex;
    if (start > 0)
        

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.