backtrader.indicators.vortex module¶
Vortex Indicator Module - Vortex trend indicator.
This module provides the Vortex indicator for identifying trend direction and strength.
- Classes:
Vortex: Vortex indicator with VI+ and VI- lines.
示例
- class MyStrategy(bt.Strategy):
- def __init__(self):
self.vortex = bt.indicators.Vortex(self.data, period=14)
- def next(self):
# VI+ crossing above VI- indicates uptrend if self.vortex.vi_plus[0] > self.vortex.vi_minus[0]:
self.buy()
# VI- crossing above VI+ indicates downtrend elif self.vortex.vi_minus[0] > self.vortex.vi_plus[0]:
self.sell()