stratester.com

Indicators · condition block

Williams %R

Williams %R shows where the close sits within the high-low range of the last N candles, on a scale from −100 (at the low) to 0 (at the high). Readings above −20 are overbought and below −80 oversold.

How the engine evaluates it

The engine finds the highest high and lowest low of the last N candles, current candle included, and computes −100 × (highest high − close) / (highest high − lowest low). If the range is zero, %R is −50.

The comparison with the level is strict and the block is a state.

Formula
%R = −100 × (highest high N − close) / (highest high N − lowest low N)

Botscript syntax

In the Lab you pick this block from the Indicators group and fill in its fields. In the code view the same condition is written like this:

willr(14) < -80
willr(14) > -20

Settings

SettingValuesDefaultNotes
Comparison<, ><—
Level−100 – 0−80—
Length2 – 50014—
Timeframethe run's candles, or 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1wthe run's candlesOptional. At least the run's candle size and a whole multiple of it.

On a higher timeframe

Add a timeframe at the end to read Williams %R from bigger candles than the run uses, for example willr(14) < -80 on 4h. The engine builds those candles from the run's own candles (UTC, weeks start on Monday) and evaluates the block only on candles that have closed, so there is no look-ahead. Lengths and lookbacks count the bigger candles.

Williams %R is a state on a higher timeframe: the result from the last completed bigger candle holds on every run candle until the next one closes.

The timeframe must be at least the run's candle size and a whole multiple of it; otherwise the run stops with an error and is not charged. Multi-timeframe conditions covers the details, including warm-up.

How traders use it

  • Short-term dips: willr(14) < -80.
  • Exits on strength: willr(14) > -20.

Example bot

botscript
bot "Williams Dip"

when willr(14) < -90 and cooldown 12
then buy 50%

when willr(14) > -20
then sell 100%
  • Buys when %R is deeply oversold, at most once every 12 candles.
  • Sells when %R reaches overbought.

Pitfalls

  • %R is fast and noisy, especially on small candle sizes.
  • It stays pinned near 0 or −100 in strong trends.

Williams %R: frequently asked questions

Why is Williams %R negative?

Larry Williams defined it as the distance from the high, so it runs from −100 to 0.

How is it related to the stochastic?

%R equals raw stochastic %K minus 100.

Does the current candle count in the range?

Yes, the window is the last N candles including the current one.

What if the high equals the low?

%R is set to −50.

Simulated results are hypothetical. They include only the fee and slippage you set on the bot, not every real-world cost or market condition, and past performance does not guarantee future results. Nothing here is financial advice.