DocsStrategy APIindicators

WILLIAMSR (Williams %R)

Williams %R is a fast momentum oscillator that shows the current closing price relative to the high-low range over a period. It ranges from -100 (oversold) to 0 (overbought).

Declaration

function init(ctx) { ctx.indicator('willr', 'WILLIAMSR', { period: 14 }); }

Options

OptionTypeDefaultDescription
periodnumber14Lookback period

Output

Returns a single number[] series with values between -100 and 0.

Accessing Values

function onBar(ctx, i) { const willr = ctx.ind.willr[i]; }

Use Cases

Reversal Trading

function onBar(ctx, i) { const willr = ctx.ind.willr[i]; if (willr < -80) { ctx.order.market('ASSET', 1, { signal: 'buy', reason: 'willr_oversold' }); } if (willr > -20) { ctx.order.close('ASSET', { signal: 'sell', reason: 'willr_overbought' }); } }

Value Ranges

RangeInterpretation
-100 to -80Oversold
-80 to -20Neutral
-20 to 0Overbought

Calculation

$$%R = \frac{Highest High - Close}{Highest High - Lowest Low} \times -100$$

Related

  • STOCH - Similar concept with %K/%D lines
  • RSI - Momentum using gains/losses
  • CCI - Mean deviation oscillator
indicatorwilliamsrwilliamsmomentumoscillatorqsl