Calculate first, then assign the upper and lower labels
Zerodha documents the HLC formulas; Frank Ochoa explicitly notes that their TC and BC results can exchange positions. Keep raw values during debugging, then assign chart labels by numerical order. The pivot is halfway between the two outer levels. If both outer values are equal, all three lines coincide.
| Value | Calculation | Meaning |
|---|---|---|
| Pivot | (H + L + C) / 3 | Central line |
| Raw BC | (H + L) / 2 | Midpoint of the reference high and low |
| Raw TC | 2 × Pivot - raw BC | Reflection of raw BC across Pivot |
| Displayed BC | min(raw BC, raw TC) | Lower boundary |
| Displayed TC | max(raw BC, raw TC) | Upper boundary |
| Width | Displayed TC - displayed BC | Nonnegative distance between boundaries |