Percent R Trend Exhaustion runs two Williams %R at once โ a fast one and a slow one โ and marks the stretches where both are pinned at the same extreme. Those stretches get a box on the price chart. The bar where the stretch ends gets an arrow. It works on MT4 and MT5.

Two lengths, one condition
Fast is 21 bars smoothed over 7. Slow is 112 bars smoothed over 3. Both plotted, both on the same โ100 to 0 scale.
Overbought needs both lines at or above โ20. Oversold needs both at or below โ80. One line stretched is ordinary; two lines stretched at two different timescales is the thing this indicator exists to find, and it's much rarer.
InpThreshold moves both levels together โ at 20 you get โ20 and โ80, at 10 you get โ10 and โ90 and far fewer boxes.
There's a second mode. InpFormula set to Average replaces the two-line test with a single 3-bar moving average of both, so one condition instead of two. It's more forgiving and produces more boxes; the standard mode is the default and the stricter of the two.
The box is not a sell signal
This is the part worth being clear about, because the colours invite the opposite reading.
A red box marks a period where both oscillators were pinned at the top. That is exactly what a strong uptrend looks like. Look at the large red box on the gold chart above: it covers a clean two-day rally, and price kept going after it. A trader who read it as "overbought, sell" was fighting the strongest part of the move.
The box says the trend is running hot. The arrow says it stopped. Those are different bars and the difference is the whole idea โ the alert text in the code even distinguishes them: one fires when a trend "has started, watch for exhaustion", the other when it "exhausted".
If you want one thing to act on, it's the arrow.

| One Williams %R | Stochastic | This | |
|---|---|---|---|
| Lines | One | Two, same length family | Two, 21 and 112 |
| Overbought means | One line above a level | %K above a level | Both lines above the level |
| Marked on price chart | No | No | Yes, a box over the whole stretch |
| Signal | Level crossed | %K crosses %D | The stretch ending |
| Frequency | High | High | Low |
What you get
The two %R lines with five level lines, an optional average line, the arrows, and up to InpMaxBoxes boxes drawn on the price chart, filled or outline only.
Four alerts, each switchable: overbought trend start, oversold trend start, overbought exhaustion and oversold exhaustion. Plus two extra signal layers that are off by default: arrows for crossings of the โ50 midline, and highlighting of fast/slow crossovers.
Notifications go through the shared block โ alert, email, push or Telegram.
Where it's weak
Notifications are off by default. InpNotiType starts at none, so the four alert switches do nothing until you set it. That's the first thing to change.
The boxes are opaque. MetaTrader rectangles have no transparency, so a filled box is a solid block with the candles drawn over it. Set InpFillBoxes to false for outlines if it bothers you, which on a chart with several long stretches it will.
The exhaustion arrow is late, necessarily. It fires when a line leaves the zone, which is after the extreme. That's the honest cost of waiting for confirmation, and it means you are never buying the low.
No trend context. Nothing here knows whether the market is trending or ranging. In a range the oversold arrows are excellent; in a strong trend the same arrows appear repeatedly on the way up and mean much less.
Two lengths, no adaptivity. 21 and 112 are the same on every instrument and every timeframe. The 112-bar %R on M5 is under ten hours; on D1 it's most of a year.
Boxes stay after the fact. They record where the condition held, not where it holds now. Old boxes accumulate up to InpMaxBoxes and there's no visual difference between one from this morning and one from last month.
The Average mode changes the meaning of everything. Switching InpFormula makes the condition a single-line test, so the "both lines agree" idea that justifies the indicator no longer applies. It's a legitimate looser setting; just know it isn't the same tool.
Questions you'll have
Does it repaint? The %R values on closed bars don't change. A box that is still open extends as long as the condition holds, and the arrow is placed on the bar where it broke.
Should I sell when a red box appears? No. A red box means both oscillators are stretched, which is what a strong uptrend does. The arrow at the end of the box is the reversal marker.
Why are there so few boxes? Because both %R have to be past the level at the same time, and one is 112 bars long. Lower InpThreshold for even fewer, raise it for more.
What's the difference between the two formulas? Standard requires both lines past the level. Average uses a 3-bar mean of the two and tests it once, which is looser.
Why am I not getting alerts? InpNotiType defaults to none. Set it, then pick which of the four events you want.
Can I turn off the boxes? Yes, InpDrawBoxes. Or keep them as outlines with InpFillBoxes off.
What are the extra signals? Midline crossings at โ50 and fast/slow crossovers. Both off by default, both add a lot of arrows.
Can an EA read it? Yes. The fast %R, slow %R and the average are all plotted buffers.
Best timeframe? H1 and H4. The slow length of 112 needs a timeframe where that many bars is a meaningful window.
MT4? Both platforms are included, one download each. Same two lines, same condition, same boxes.
Support
Send me a message with a screenshot, the symbol and the timeframe, and I'll tell you what the tool was doing on that bar.
Analysis tool. It places no trades and makes no profitability claim. Past price behaviour is not a guide to future price behaviour.