I'm trying to create Elder Force Index with ATR Channels so that I can backtest a strategy that involves this indicator. Someone has already written the code in TradingView so I'm essentially just trying to reproduce that code in QuantConnect.
I've created the EFI using a deque and I've applied the EMA. I'm stuck on line 74 where it performs the ATR on the indicator data. The documentation in QC shows how to use IndicatorExtensions but I'm not sure it works in this scenario.
Can anyone point me to documentation that shows how to pump custom indicator values from a deque and build a new list off of that in QC? Heck, maybe this particular indicator already exists and I don't need to create it myself. That would be dandy! =)
In the meantime, I'm going to complete more of the courses and hopefully discover something there that will help me think differently about this obstacle. Looking forward to any assistance.
Mak K
Hi Jason,
What exactly do you want to feed into the ATR indicator?
It is not yet clear to me what you are doing here exactly but maybe this could be helpful to you
https://lean-api-docs.netlify.app/classQuantConnect_1_1Indicators_1_1IndicatorExtensions.html#:~:text=%E2%97%86%C2%A0-,Of%3C%20T,-%3E()
Jason Annable
Thank you. I have looked into IndicatorExtensions but am unsure how to use them in this context. Basically, for every point on an EMA, I need to compute the difference from the previous EMA value and then use that to compute the ATR channels from the EMA line.
Mak K
Could you explain what the ATR channels are? Are they just multiple “normal” ATR indicators?
Fred Painchaud
Hi Jason, Mak,
Just wanting to add a lil something here.
I am using line 74 in the TV indie: atr_ema = math.abs(efi[1] - efi)
I am guessing you are stuck on trying to find a way to access efi[1] and efi. You are saying you have a deque.
So:
Of course, assuming the name of your deque variable is “my_deque”.
Now that you know out to get the values for the series passed to RMA on line 75 (atr_out = RMA(atr_ema, calc_type == "Fixed" ? len : len_out_slow) ), you just need to create an RMA indicator (Wilder's MA) and use its Update() method to push those values to it. Once it is ready, you're ready.
In fact, I first thought RMA was not already in QC's indies because I searched for RMA. But it looks like it is WilderMovingAverage. Create it using the long name “WilderMovingAverage” so you can update it yourself instead of LEAN updating it on each bar (you do not want LEAN to update it with bar data but you updating it with distance data (abs(old_value - recent_value) is distance between values).
Fred
Jason Annable
Fred, thank you. You understand what I mean. I'll unpack your suggestion and try it out this evening.
Mak, ATR channels are a factor of 1, 2, and 3 times the EMA delta away from the EMA line. The TV code that I linked to in the original post probably explains it better.
Vladimir
A very similar picture.
Used self.History and talib functions.
Let me know if you will see it...
Jason Annable
Ya, I'm not sure how to get past the block I'm experiencing. I've attached the latest backtest. Thinking it's foobared and need to start fresh.
Vladimir
Jason Annable,
As I mentioned above, it is fairly easy to calculate the Elder Force Index using the self.History and talib functions.
What is related to the TV code of ATR channels it has nothing to do with the Average True Range Indicator.
So I decided to recreate these channels using talib. ATR () and talib.SMA (volumes).
The picture is very similar to the one on TV.
Happy Holidays.
Jason Annable
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!