backtrader.indicators.williams module

Williams Indicator Module - Williams %R indicator.

This module provides the WilliamsR indicator developed by Larry Williams to show overbought/oversold conditions.

Classes:

WilliamsR: Williams %R indicator.

Example

class MyStrategy(bt.Strategy):
def __init__(self):

self.williamsr = bt.indicators.WilliamsR(self.data, period=14)

def next(self):

# Williams %R above -20 indicates overbought if self.williamsr.percR[0] > -20:

self.sell()

# Williams %R below -80 indicates oversold elif self.williamsr.percR[0] < -80:

self.buy()

class backtrader.indicators.williams.WilliamsR[source]

Bases: Indicator

Developed by Larry Williams to show the relation of closing prices to the highest-lowest range of a given period.

Known as Williams %R (but % is not allowed in Python identifiers)

Formula:
  • num = highest_period - close

  • den = highestg_period - lowest_period

  • percR = (num / den) * -100.0

See:
plotinfo = <backtrader.metabase.plotinfo_obj object>
plotlines = <backtrader.metabase.plotlines_obj object>
__init__(*args, **kwargs)
next()[source]

Calculate Williams %R for the current bar.

%R = -100 * (highest - close) / (highest - lowest) Returns 0.0 if denominator is 0 to avoid division by zero.

once(start, end)[source]

Calculate Williams %R in runonce mode.

Computes %R values across all bars.

frompackages = ()
packages = ()
class backtrader.indicators.williams.WilliamsAD[source]

Bases: Indicator

By Larry Williams. It does cumulatively measure if the price is accumulating (upwards) or distributing (downwards) by using the concept of UpDays and DownDays.

Prices can go upwards but do so in a fashion that no longer shows accumulation because updays and downdays are canceling out each other, creating a divergence.

See: - http://www.metastock.com/Customer/Resources/TAAZ/?p=125 - http://ta.mql4.com/indicators/trends/williams_accumulation_distribution

__init__(*args, **kwargs)
next()[source]

Calculate Williams A/D for the current bar.

Accumulates based on up days and down days using true range.

once(start, end)[source]

Calculate Williams A/D in runonce mode.

Accumulates values across all bars.

frompackages = ()
packages = ()