Indicators
Choose the correct Donchian window for a breakout test

Specify the boundary before the test
Define the upper boundary as the highest high of the previous three completed bars. Define the event as today's close strictly above that boundary. This wording fixes the window, observation time and comparison operator. Some indicators plot a channel including the current bar; that drawing can be valid for a different use.
Run a four-bar example
Let the previous three highs be 100, 102 and 101. Today's high is 105 and its close is 104. The prior upper boundary is 102, so the close exceeds it by 2. A channel including today shows 105 instead. The same close cannot exceed that value since a valid candle closes at or below its own high.
104 > max(100, 102, 101)
Separate a touch from a break
Change today's close to 102 while keeping its high at 105. The intrabar high breached the prior channel; the close only touched it. A greater-than-or-equal comparison would include this bar, while a strict close breakout would exclude it. Choose which event you intend before counting examples.
Check indexing with one saved timestamp
On a newly opened bar, the just-completed candle is at shift 1. To test that closed candle against the previous three highs, take shifts 2 through 4. Log both the time of the candidate and the times of the highs used. Repeat on the lower boundary with lows and a strict less-than comparison.
















