Back

Question about using D+ and D- of ADX

I am new at Quantconnect and I am trying to determine the trend using ADX. My plan is to determine the strength of the trend using ADX value, and determining direction comparing D+ and D-. However, after consulting the documentation, I haven't figured out how to access those values correctly, any tips? Thanks

def determine_trend(self):
trending = self.adx.Current.Value >= ADX_MIN_VALUE_FOR_TREND
up = self.adx.PositiveDirectionalIndex.Value > self.adx.NegativeDirectionalIndex.Value
down = self.adx.NegativeDirectionalIndex.Value > self.PositiveDirectionalIndex.Value
return trending, up, down

The error I get is 

Runtime Error: AttributeError : '0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'Value'
at OnData in main.py:line 48
at determine_trend in main.py:line 53
AttributeError : '0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'Value' (Open Stacktrace)

Update Backtest







For the indicator properties like PositiveDirectionalIndex and NegativeDirectionalIndex, you should also use the Current.Value to retrieve the value

For example self.adx.PositiveDirectionalIndex.Value.

0


That worked, thanks

0

Update Backtest





0

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.


Loading...

This discussion is closed