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[源代码]¶
基类:
PeriodNDefined 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
gammais meant to have values between0.2and0.8, with the best balance found theoretically at the default of0.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[源代码]¶
基类:
PeriodNDefined by John F. Ehlers in Cybernetic Analysis for Stock and Futures, 2004, published by Wiley. ISBN: 978-0-471-46307-8
gammais meant to have values between0.2and0.8, with the best balance found theoretically at the default of0.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的别名