Intermediate Trading Tutorial — Confirmed Directional Range Displacement in ProRealTime

A higher high is not necessarily accompanied by a higher low. A candle can expand in both directions and produce a higher high while its lower boundary moves downward. Such a candle differs geometrically from a candle whose entire price interval has migrated upward. This tutorial develops a native ProBuilder indicator that requires both boundaries to move in the same direction before classifying a directional displacement event. It summarizes the frequency of these events over completed candles and reports upward frequency, downward frequency and their difference. The statistic is intended to describe historical interval behavior, not forecast returns.

Define a directional event

For every evaluated candle, subtract the previous high from the current high and the previous low from the current low. Let the two differences be DH and DL. Set a nonnegative minimum movement T in raw price units. A candidate qualifies upward only when DH and DL are both strictly greater than T. A candidate qualifies downward only when both differences are strictly smaller than negative T. All other arrangements are neutral. The neutral category therefore includes range expansion in opposite directions, contraction in opposite directions, unchanged boundaries and any movement that fails the chosen threshold.

This definition does not require nonoverlapping intervals. Two successive candles can share much of their price territory and still qualify upward if both boundaries are higher. It also does not use the opening or closing price, so a bearish-bodied candle can qualify upward. The classification asks whether both observed boundaries migrated in the same direction, not whether buyers or sellers initiated more trades. These distinctions are important when comparing the indicator with candle-body studies, gap scanners and traditional directional movement indicators.

Confirmed Directional Range Displacement Indicator
Four hypothetical ranges are 100–106, 102–109, 101–110 and 99–107. Their three adjacent comparisons are upward, mixed and downward. With a zero minimum movement, the signed scores +1, 0 and −1 average to zero.

Worked numerical examples

Set sampleLength to three and minimumMove to zero. The first interval extends from 100 to 106. The next interval extends from 102 to 109. The high increases by three and the low increases by two, so the event qualifies upward. The third interval is 101 to 110: the high rises by one while the low falls by one. This is neutral. The fourth interval is 99 to 107, giving a high change of −3 and a low change of −2, so it qualifies downward.

One of the three comparisons is upward and one is downward. Each directional frequency is approximately 33.33%. Their difference is zero percentage points. The remaining one-third of the sample is neutral. A zero net result therefore does not mean that no directional events occurred. It can represent opposing events that balance one another. Displaying both components helps distinguish this situation from an entirely neutral sample.

Now apply a minimum movement of two price units to the same example. The first event has changes of +3 and +2, and the last has changes of −3 and −2. Both fail the strict comparison because one boundary lies exactly on its threshold. The mixed event remains neutral. All three outputs are zero. If the minimum were one instead, the first and last events would qualify again. These hypothetical examples demonstrate why the choice between strict and inclusive inequalities must be documented rather than left implicit.

Complete native ProBuilder source

// PatternSmart: confirmed directional range displacement
// Edit these settings or expose them as indicator variables.
sampleLength = 20
minimumMove = 0

upCount = 0
downCount = 0
upPct = undefined
downPct = undefined
netScore = undefined

// N comparisons need N+1 completed bars.
// Offset zero is deliberately excluded.
IF sampleLength >= 1 AND minimumMove >= 0 THEN
 IF BarIndex >= sampleLength + 1 THEN
  validSample = 1
  FOR i = 1 TO sampleLength DO
   IF High[i] < Low[i] OR High[i+1] < Low[i+1] THEN
    validSample = 0
   ENDIF
   highChange = High[i] - High[i+1]
   lowChange = Low[i] - Low[i+1]

   // Both boundaries must move in the same direction.
   IF highChange > minimumMove AND lowChange > minimumMove THEN
    upCount = upCount + 1
   ELSIF highChange < -minimumMove AND lowChange < -minimumMove THEN
    downCount = downCount + 1
   ENDIF
  NEXT
  IF validSample = 1 THEN
   upPct = 100 * upCount / sampleLength
   downPct = 100 * downCount / sampleLength
   netScore = upPct - downPct
  ENDIF
 ENDIF
ENDIF

RETURN upPct COLOURED(36,145,100) AS "Up frequency", downPct COLOURED(190,65,65) AS "Down frequency", netScore COLOURED(45,105,190) AS "Net displacement"

Historical indexing and output construction

In ProBuilder, High[i] and Low[i] access historical candle values at the specified bars-back offset. The current display candle has offset zero. The loop begins at one and extends through sampleLength. Each comparison also requires the preceding candle at i+1. The largest historical offset is consequently sampleLength plus one. BarIndex begins at zero, and the history condition prevents the loop from accessing candles before the available chart history. Use a positive integer sampleLength and a nonnegative minimumMove.

Upward and downward counts are reset at each calculation rather than carried forward as mutable state. Each qualifying event contributes exactly one count to its respective direction. The denominator is the full sample, including neutral events. Multiplying each count by one hundred and dividing by sampleLength produces the directional percentages. The third plot is their difference in percentage points. Both component frequencies are bounded between zero and one hundred; their sum cannot exceed one hundred. The net is bounded between minus one hundred and plus one hundred.

The implementation uses undefined for unavailable output, keeping insufficient history separate from a valid zero. A reversed high-low interval invalidates the entire sample instead of silently reducing the denominator. The code assumes ordinary finite price data supplied by the chart. Each evaluation performs a number of comparisons proportional to sampleLength. This direct calculation is intended to be easy to audit. A rolling optimization can be developed later, provided it preserves the strict thresholds, sample boundaries and invalid-data policy.

Installation and confirmation timing

Open the ProRealTime indicator creation interface, create a new custom ProBuilder indicator and paste the complete source. Save it and apply it in a separate indicator panel. The two settings appear as assignments at the start of the code; edit them directly for this reference version, or expose equivalent variables using the platform's indicator parameter interface. Use the data display to inspect numerical values. The source has not been compiled or executed in ProRealTime here; check syntax and behavior in your installed version before relying on it.

The current forming candle is never part of a counted comparison. The result at display index t is derived exclusively from completed candles before t. It is intentionally aligned one bar after the most recent classified event. Under unchanged history, the active candle's high or low can move without changing the displayed statistic. A new candle advances the sample and may change both counts. No future data are referenced, but historical corrections, different sessions or reconstructed chart bars can legitimately change the historical results.

Testing and limitations

Reproduce both examples in a spreadsheet. Test all-up, all-down, entirely neutral and balanced sequences. Include equal boundary changes, expanding and contracting intervals, insufficient history and a sample length of one. Verify that the active candle cannot affect the calculation before a new bar appears. Compare historical and replay observations using identical aggregation and session settings. This statistic weights every qualifying event equally regardless of its magnitude. MinimumMove is expressed in price units rather than percentage or volatility-adjusted units, so thresholds may not transfer across instruments. The indicator ignores transaction sequence, volume, spread and execution constraints. Overlapping windows are statistically dependent. Test downstream hypotheses on independent data with realistic costs.

For volatility-adjusted thresholds, alerts or integration with other ProBuilder indicators, contact our Custom ProRealTime indicator Development Services.

Risk disclosure: educational material only. Trading involves risk of loss. Hypothetical examples do not establish profitability.

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.