Skip to main content
BTC / USDT——ETH / USDT——SOL / USDT——BNB / USDT——XRP / USDT——DOGE / USDT——TON / USDT——AVAX / USDT——LINK / USDT——ADA / USDT——TRX / USDT——DOT / USDT——BTC / USDT——ETH / USDT——SOL / USDT——BNB / USDT——XRP / USDT——DOGE / USDT——TON / USDT——AVAX / USDT——LINK / USDT——ADA / USDT——TRX / USDT——DOT / USDT——
Preise

Williams %R

Overbought/oversold momentum oscillator — TradingView, TradeStation and MetaStock code.

Williams %R plots where the current close sits inside the high–low range of the last N bars, scaled 0 (top) to −100 (bottom). Readings above −20 are overbought and below −80 oversold; traders also watch failure swings and divergences to time reversals. Copy the version for your platform.

MQL4 · WilliamsR.mq4
#property indicator_separate_window
#property indicator_buffers 1

input int WPRPeriod = 14;

double WPRBuffer[];

int OnInit() {
  SetIndexBuffer(0, WPRBuffer);
  IndicatorShortName("Williams %R");
  return 0;
}

int OnCalculate(const int rates_total, const int prev_calculated, const double &close[]) {
  for (int i = 0; i < rates_total; i++) {
    WPRBuffer[i] = iWPR(NULL, 0, WPRPeriod, i);
  }
  return rates_total;
}
MQL5 · WilliamsR.mq5
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1

input int WPRPeriod = 14;

double WPRBuffer[];

int OnInit() {
  SetIndexBuffer(0, WPRBuffer, INDICATOR_DATA);
  IndicatorSetString(INDICATOR_SHORTNAME, "Williams %R");
  return INIT_SUCCEEDED;
}

int OnCalculate(const int rates_total, const int prev_calculated,
                const datetime &time[], const double &open[],
                const double &high[], const double &low[],
                const double &close[], const long &tick_volume[],
                const long &volume[], const int &spread[]) {
  for (int i = 0; i < rates_total; i++) {
    WPRBuffer[i] = iWPR(_Symbol, PERIOD_CURRENT, WPRPeriod);
  }
  return rates_total;
}
Pine Script
//@version=5
indicator("Williams %R")
length = input.int(14, "Length")
plot(ta.wpr(length), "Williams %R", color=color.red)
EasyLanguage
inputs: Length(14);
Plot1(WilliamsR(Length), "Williams %R");
MetaStock
WillR(14)

To use it inside dtcharts, paste any version into the Script Converter and it becomes a native indicator on your chart.