Risk & Levels CockpitRisk & Levels Cockpit
Risk & Levels Cockpit answers one question on any market and any timeframe: if I take this trade, where is my stop, what size should I trade, and what can I lose? It is a risk-and-levels tool, not a buy/sell signal — it does not predict direction, it bounds risk around a trade you have already decided to take.
HOW IT WORKS
Three components chain one-way:
Theil-Sen robust channel — fits a trend line as the median of all pairwise slopes over the lookback. Being a median, it cannot be tilted by a single spike or wick the way ordinary regression can, so the rails give you a stable structure to trade against.
Extreme Value Theory tail model (Peaks-Over-Threshold, Generalized Pareto) — estimates how far price can realistically move against you at a chosen tail quantile, replacing a guessed 2xATR stop with a distance grounded in the actual tail of the return distribution. The channel rail acts as a structural floor, so your stop is never tighter than the channel edge.
Fixed-fractional sizer — turns that stop into a position size: units = floor(risk-budget / (risk distance x point value)). When the stop is wider than your risk budget, size correctly floors to zero and the panel shows what one unit would cost and the capital that would make one unit equal your target risk, so a zero is a decision, not a dead end.
TWO SIZING BASES
Stop distance risks your fraction at the drawn stop. Expected Shortfall risks your fraction at the mean loss beyond the stop (McNeil-Frey POT form, from the same tail fit) — wider, so fewer units, so that gapping through your stop still respects your budget. The panel always shows both the at-stop and at-tail loss per unit, so gap risk is visible in either mode. An optional vol-target overlay (on by default) scales size to keep portfolio volatility steadier across regimes; the Size-mode row always shows the live multiplier.
WORKS ON ANY MARKET, ANY TIMEFRAME
No session, expiry, or clock anchors; every lookback is in bars and volatility annualization self-scales — identical behavior from 1-minute scalping to daily positional, on stocks, futures, forex, crypto, and indices worldwide. Set the currency symbol and point value (money per point per unit) to your instrument: stocks/crypto/spot = 1; index and futures = the contract multiplier (for example NIFTY 65, S&P E-mini 50, Nikkei 1000, DAX 25); forex = point value per lot; options = point value x delta.
A Scalp/Intraday, Positional, or Custom preset adjusts the tail horizon and quantile. Scalp/Intraday is the default (tighter stops); positional traders should switch to the Positional preset for wider, conservative stops.
ON THE CHART
A slope-colored robust trend line with a TREND pill and a channel band, plus solid, pill-labeled decision levels — red STOP, amber BREAK (invalidation), and green T1 and T2 TARGET, each showing price and R-multiple. The panel gives the full sizing and risk readout, including a daily-loss-budget line.
LIMITATIONS (read before use)
Not a signal and not investment advice. Stops and targets are model references, not guarantees — gaps and slippage can exceed them. The tail quantile is scaled to the holding horizon by square-root-of-time, a deliberate approximation chosen over overlapping h-bar fitting which violates independence. The daily-loss cap is a display aid; a single-chart indicator cannot track or enforce live fills. The vol-target overlay multiplies the fixed-fractional size and can nudge per-trade risk above the nominal percent in calm markets — set Size clamp max to 1.0 to only reduce size, or turn it off for a strict fixed-percent rule. Position sizing does not create an edge; it bounds risk.
CREDITS
Original implementation. Theil (1950) and Sen (1968) robust slope; Pickands-Balkema-de Haan / Peaks-Over-Threshold Generalized Pareto tail estimation and Expected Shortfall (McNeil-Frey); fixed-fractional position sizing (Tharp / Vince).
Indicator

