All public workReview scope and boundaries
Compiler-verified open-source Pine Script v6 diagnostic
Pine v6 Partial Exit State Inspector
A deterministic Pine Script diagnostic that makes initial-versus-remaining quantity semantics explicit for 50%, 33% and 25% partial exits and emits each tier once on a confirmed bar.
The engineering problem
Why this tool exists
A request to sell 50%, then 33%, then 25% is incomplete until the percentage base is frozen. If all three refer to the initial position they total 108%; if they refer to the remaining quantity, a 100-unit fixture exits 50, 16.5 and 8.375 units and leaves 25.125.
Published capabilities
- Initial-versus-remaining quantity mode
- Deterministic 100 → 50 → 33.5 → 25.125 state ladder
- Explicit error when initial-position percentages exceed 100%
- Confirmed-bar tier transitions
- One event per tier with alerts disabled by default
Engineering evidence
- Original MPL-2.0 Pine v6 source published on GitHub
- Exact source saved in TradingView without a compile error on 2026-08-12
- Public documentation freezes the formula, expected values and limitations
- A reproducible 100-unit fixture exposes the quantity contract before implementation
What this case study does not claim
- The script is a state diagnostic; it does not create entries, operate a broker account or claim trading performance.
- The TradingView Basic-plan indicator cap prevented an on-chart transport test, so no chart, alert or broker acceptance is claimed.
- The remaining-quantity model is a contract fixture; broker lot steps, fills and slippage remain outside scope.
Need related custom work?