xKen-t Williams %R + EMA w/COT Bias GateWhat's original here
This isn't a Williams %R repaint. Standard %R gives a level; this script converts it into a filtered, context-aware timing engine through four combined mechanisms: (1) exit-from-extreme triggers that fire when %R crosses back out of −80/−20 rather than when it reaches them, so signals mark the reversal instead of the ongoing move; (2) EMA-side confirmation that validates the exit against the 13-EMA; (3) a −50 regime filter that blocks counter-regime signals; and (4) a directional-bias gate that normalizes any external series you feed it (e.g. a COT commercial-net line) to a 0–100 position-in-range index and suppresses every signal that disagrees with that bias. The gate is the core idea — it makes the oscillator time entries only in a separately chosen direction, turning a reversal oscillator into a with-context pullback tool. A status table surfaces %R, its EMA, the regime, the active bias, the higher-timeframe read, and the last signal in one place.
Overview
A Williams %R momentum tool rebuilt around three ideas: it signals on the exit from an extreme rather than the touch, confirms that exit with the %R/EMA relationship, and can gate every signal by an external directional bias (such as Commitments of Traders positioning) so only signals agreeing with that bias are shown. This targets the two classic Williams %R weaknesses — catching falling knives at the band, and firing endless counter-trend reversals during strong trends.
What it calculates
- Williams %R (default 21): the standard oscillator (0 to −100) measuring where the close sits within the lookback's high-low range.
- 13-EMA of %R: a smoothing/confirmation line.
- Triggers: in "Band exit" mode a long fires when %R crosses back up through −80 (leaving oversold) and a short when it crosses back down through −20 (leaving overbought). In "EMA cross in zone" mode the trigger is %R crossing its EMA while in the lower/upper half. Either way, it marks the turn, not the extreme reading itself.
- EMA confirmation (optional): requires %R on the trigger side of its EMA at signal time.
Regime filter (optional): longs only when the %R EMA is above the −50 midline, shorts only when below.
- COT Bias Gate: point the "COT source" input at any external series on the chart — e.g. a Commitments of Traders commercial-net or COT-index line. The script converts it to a 0–100 position-in-range index over a lookback; ≥80 is treated as bullish bias, ≤20 as bearish. With the gate on, longs show only in a bullish bias and shorts only in a bearish one; opposite-bias signals are suppressed. You can also set the bias manually or turn the gate off for standalone %R.
- Divergence (optional): regular bull/bear divergence between price pivots and %R pivots.
Higher-timeframe read (optional): shows a higher-timeframe %R value in the table for top-down context.
How to use it
1. Add it on your entry timeframe (defaults: %R 21, EMA 13, band-exit, EMA confirmation on).
2. Set the bias — manually (Bullish/Bearish), or "Auto" pointed at a COT/context line, or Off.
3. Trade the markers: green up-triangle = confirmed long trigger, red down-triangle = confirmed short. Combine with your own levels and risk management.
Notes and limitations
- Divergence markers are drawn back at the confirmed pivot using an offset — they plot in the past and can repaint until the pivot forms. Treat them as context, not a standalone trigger.
- The gate reads whatever series feeds the source input; on the default (Close) the "bias" is computed from price, not COT — point it at a real COT/context line for it to be meaningful.
- The higher-timeframe read uses non-lookahead requests (no future data).
- Analysis tool for timing within a chosen bias. It does not predict outcomes and is not financial advice.
Chỉ báo






















