Hey! I'm migrating from Quantopian to QuantConnect due to some limitations over there. I haven't used C# is years (5-10?) and even at that time I wasn't very deep into it.
Over the last few months I've got a pretty good handle on Python but figured I'd give C# a go on this platform. With Python I could just use TALib to calculate the indicators for me but now I'd like to work them out in C#. I'm a little stuck as to how to go about making a function to calc the DI+ and DI- . A little help would be appreciated, with some examples I should be able to throw something together. Thanks!
Alexandre Catarino
Please checkout the docs under Indicators section. There you can find a reference table with all supported indicators (we try to cover all the mainstream indicators). We have ADX in our library. We can use the ADX method to create a self-updating ADX with the desired resolution. Example:
private AverageDirectionalIndex _adx; // In Initialize: _adx = ADX("SPY", 14, Resolution.Daily); // In OnData: var diplus = _adx.PositiveDirectionalIndex; var diminus = _adx.NegativeDirectionalIndex;
Andy Visser
Perfect! I apologize, I wasn't aware that I could pull these numbers from the indicator, thanks a bunch!
Alexandre Catarino
Please checkout the attached project for a working example.
The ADX was set as:
_adx = ADX("SPY", 14*8, Resolution.Hour);
When there is no open positions, we buy if DI+ is greater than DI- (with a tolerance to avoid bouncing) and sell otherwise. At the end of day (market is closed), we liquidate the position. That means a MarketOnOpenOrder will be issued.
Andy Visser
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!