The condition `idxRecalcFrom < drawBegin` inside the `case 0:` and `case 1:` branches of `CSubIndiBase::prepareBeforeCalculating` is mathematically unreachable because all sub-indicators are guaranteed to be instantiated during `OnInit()`.
Proof:
1. `prev_calculated` on a new tick is either 0 or the value returned by `OnCalculate` on the previous tick (which is `rates_total`).
2. `CIndicatorBase::onCalculate` returns `rates_total` only if `CSubIndiRegistry::checkRatesTotal` succeeds.
3. `checkRatesTotal` ensures that `rates_total >= CSubIndiRegistry::barsRequired`.
4. Therefore, any non-zero `prev_calculated` is strictly `>= CSubIndiRegistry::barsRequired`.
5. Since all sub-indicators are created in `OnInit`, the global registry's `barsRequired` is the maximum of all instances' `barsRequired`. Thus, `CSubIndiRegistry::barsRequired >= instance.barsRequired`.
6. Inside `prepareBeforeCalculating`, branches `case 0` and `case 1` are only reached when `rates_total - prev_calculated` is 0 or 1. Given `rates_total >= 3` (minimum allowed bars), `prev_calculated` cannot be 0 (otherwise the difference would be >= 3, falling into the `default` branch).
7. Since `prev_calculated > 0`, we establish that `prev_calculated >= instance.barsRequired`.
8. The code calculates: `idxRecalcFrom = prev_calculated - 1`.
9. By substitution: `idxRecalcFrom >= instance.barsRequired - 1`.
10. Since `drawBegin` is strictly initialized to `barsRequired - 1` in the constructor, we conclude that `idxRecalcFrom >= drawBegin` is always true.
Consequently, `idxRecalcFrom < drawBegin` will always evaluate to false, rendering the check dead code.
rates_total and prev_calculated are typically declared as const throughout the
codebase, so add const here as well to keep the signature consistent with the
usual convention.