backtrader.indicators.lrsi module

Laguerre RSI Module - Laguerre filter-based RSI.

This module provides the LaguerreRSI indicator defined by John F. Ehlers for faster reaction to price changes using Laguerre filters.

Classes:

LaguerreRSI: Laguerre RSI indicator (alias: LRSI). LaguerreFilter: Laguerre filter (alias: LAGF).

示例

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

self.lrsi = bt.indicators.LRSI(self.data, gamma=0.5) self.lfilter = bt.indicators.LAGF(self.data, gamma=0.5)

def next(self):
if self.lrsi.lrsi[0] > 0.8:

self.sell()

elif self.lrsi.lrsi[0] < 0.2:

self.buy()

class backtrader.indicators.lrsi.LaguerreRSI[源代码]

基类:PeriodN

Defined by John F. Ehlers in Cybernetic Analysis for Stock and Futures, 2004, published by Wiley. ISBN: 978-0-471-46307-8

The Laguerre RSI tries to implement a better RSI by providing a sort of Time Warp without Time Travel using a Laguerre filter. This provides for faster reactions to price changes

gamma is meant to have values between 0.2 and 0.8, with the best balance found theoretically at the default of 0.5

alias = ('LRSI',)
plotinfo = <backtrader.metabase.plotinfo_obj object>
l0 = 0.0
l1 = 0.0
l2 = 0.0
l3 = 0.0
next()[源代码]

Calculate Laguerre RSI for the current bar.

Calculates L0-L3 Laguerre filter values and computes the RSI-style ratio of upward changes to total changes.

frompackages = ()
once(start, end)

Implement once using next for batch calculation.

This is used when next is overridden but once is not. It loops through the range and calls next for each step.

参数:
  • start -- Starting index

  • end -- Ending index

oncestart(start, end)

Implement oncestart using nextstart for batch calculation.

This is used when nextstart is overridden but oncestart is not.

参数:
  • start -- Starting index

  • end -- Ending index

packages = ()
preonce(start, end)

Implement preonce using prenext for batch calculation.

This is a generic implementation if prenext is overridden but preonce is not. It loops through the range and calls prenext for each step.

参数:
  • start -- Starting index

  • end -- Ending index

backtrader.indicators.lrsi.LRSI

LaguerreRSI 的别名

class backtrader.indicators.lrsi.LaguerreFilter[源代码]

基类:PeriodN

Defined by John F. Ehlers in Cybernetic Analysis for Stock and Futures, 2004, published by Wiley. ISBN: 978-0-471-46307-8

gamma is meant to have values between 0.2 and 0.8, with the best balance found theoretically at the default of 0.5

alias = ('LAGF',)
plotinfo = <backtrader.metabase.plotinfo_obj object>
l0 = 0.0
l1 = 0.0
l2 = 0.0
l3 = 0.0
next()[源代码]

Calculate Laguerre filter for the current bar.

Computes L0-L3 Laguerre filter values and outputs the weighted average (l0 + 2*l1 + 2*l2 + l3) / 6.

frompackages = ()
once(start, end)

Implement once using next for batch calculation.

This is used when next is overridden but once is not. It loops through the range and calls next for each step.

参数:
  • start -- Starting index

  • end -- Ending index

oncestart(start, end)

Implement oncestart using nextstart for batch calculation.

This is used when nextstart is overridden but oncestart is not.

参数:
  • start -- Starting index

  • end -- Ending index

packages = ()
preonce(start, end)

Implement preonce using prenext for batch calculation.

This is a generic implementation if prenext is overridden but preonce is not. It loops through the range and calls prenext for each step.

参数:
  • start -- Starting index

  • end -- Ending index

backtrader.indicators.lrsi.LAGF

LaguerreFilter 的别名