Apologies, this is a bit of a newbie question.
I am attempting to use indicator extensions for a calculation that also requires the absolute value of the MACD histogram. I keep getting an error message "TypeError: bad operand type for abs(): 'Identity", when I use abs() however. I've tried a few other things but keep running into the same issues.
Thanks everyone.
Shile Wen
Hi David,
To do this, we can instead create a custom indicator object (e.g. SimpleMovingAverage) and update the custom indicator with the absolute value of our MACD indicator whenever our MACD indicator is updated. I’ve shown how to do this in the attached backtest.
Best,
Shile Wen
Vandelay Industries
Thanks very much for your help.
I've played around with the code and can't seem to get the desired numbers unfortunately. I'm a bit confused by the use of self.sma. Is this being used as a placeholder? Is it only storing the MACD line values, rather than the absolute histogram and signal values as well? I'm also trying to get this to work with a four hour timeframe on the AUDUSD ccy pair and need the values to work within a rolling window. Essentially the calculation I'm trying to get is (abs(macd histogram)/0.1) - ATR.
Further, do the Indicator Extensions not work with the ATR indicator? I'm not having much luck there either.
Vandelay Industries
My apologies. Please disregard my previous query re: Indicator extensions and the ATR indicator. I've managed to get that to work.
Vandelay Industries
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!