direction = uptrend + downtrend
if direction.iloc[0] == 0:
direction.iloc[0] = 1
direction = direction.replace(0, nan).ffill()
# Offset
if offset != 0:
long = long.shift(offset)
short = short.shift(offset)
direction = short.shift(offset)
If you add a nonzero offset, the direction column is replaced with the shifted short column. In reality you would want the direction column to be shifted itself.
Here is what I believe to be the corrected version (only the last line is changed):
direction = uptrend + downtrend
if direction.iloc[0] == 0:
direction.iloc[0] = 1
direction = direction.replace(0, nan).ffill()
# Offset
if offset != 0:
long = long.shift(offset)
short = short.shift(offset)
direction = direction.shift(offset)
Which version are you running? The lastest version is on Github. Pip is for major releases. I am using python 3.9 and pandas_ta 0.4.19b0 (dev branch).
Do you have TA Lib also installed in your environment? no
There is a bug in the development branch of the volatility indicator "Chandelier Exit", see here: https://github.com/twopirllc/pandas-ta/blob/438f3a97b71b26bc17efb1a204fb0e0fdc48e0aa/pandas_ta/volatility/chandelier_exit.py#L108
If you add a nonzero offset, the direction column is replaced with the shifted short column. In reality you would want the direction column to be shifted itself. Here is what I believe to be the corrected version (only the last line is changed):