Hi members, I am trying to achieve below for my algorithm:
- I have created an Indicator which tracks 200 period Moving average:
self.slow = ExponentialMovingAverage(200)
2. I want to know what was the lowest 200 period Moving average value of my Moving average indicator(slow), so I am trying to use Minimum indicator for it.
self.ma200FiftyTwoLow = Minimum(200)
Now my question is how do I use RegisterIndicator() function such that my ma200FiftyTwoLow will be updated with my new values of slow?
Can I use something like below?
RegisterIndicator(self.symbol,self.ma200FiftyTwoLow, self.slow.Current.Value)
Log Up
I tried this, but its not working:
self.ma200FiftyTwoLowChained.Current.Value is always returning as 0.0 and IsReady is False too.
Fred Painchaud
Hi,
Is your ExponentialMovingAverage being updated with data points? It seems like it is not. self.EMA() is auto-updated. Or you need to manually update ExponentialMovingAverage.
Fred
Log Up
Hi Fred, it is not EMA(), I need to create it manually and register it for update. Do I need to use EMA() for it?
Fred Painchaud
Hi,
Go through
You'll find examples of manual indicators creation and manual updates. An indicator is manually updated by calling its Update() method.
Fred
Log Up
HI Fred, I am not facing difficulties in manually updating it. I want to chain it to my MIN indicator to get 252 day minimum value of 200 Moving Average.
Fred Painchaud
Hi,
Ok so we need to get to the same page.
You asked about how to register your Min indicator, which you want to take the last 200 EMA-200 values.
I asked you if your EMA indie was registered or not because you said your Min indie only outputs 0. The main and almost only reason I see your Min indie outputting 0 is if your EMA-200 indie outputs 0 all the time. The only reason I see your EMA-200 indie outputting 0 all the time is if it is not registered and not getting data. This is reinforced by you saying that your EMA-200 indie is also never ready.
In the code you posted, you use ExponentialMovingAverage(200) which is not auto-updated. You also posted that you used the extension MIN, which is perfect. BUT your ExponentialMovingAverage(200) needs to get data so it processes EMA-200 and then feeds the MIN.
So I asked is the EMA indie is getting updated or not.
If it is updated, then of course, you will have a long warmup for that. 200 bars for the first EMA-200, and it is an EMA so you need to itself prime it with more data, say 1000 bars. Then, you will need 200 more bars to get 200 values out of the EMA-200 for the MIN.
But if the EMA-200 is updated, it should become ready after 200 bars and it should then spit out values that are not 0. Unless your symbol's price is 0$ :).
Fred
Log Up
Hi Fred,
I am sorry If I caused the confusion, I did not attach backtest as algorithm is too lengthy and don't want to waste your time on it.
Even though my Exponential Moving Average Indicator is manually defined, I do populate it with history and register it for daily updates:
2. “This is reinforced by you saying that your EMA-200 indie is also never ready.”
I did not say my EMA-200 is never ready. I mentioned that my MIN indicator chained to EMA-200 is never ready:
3. "But if the EMA-200 is updated, it should become ready after 200 bars and it should then spit out values that are not 0"
I see my EMA-200 is being populated correctly with history and daily data as it is registered.
Fred Painchaud
You are right about 2. Sorry, my mistake. Let me check your code…
Fred
Log Up
Hi Fred, no worries. Thank you for your efforts :)
Fred Painchaud
Hi,
Here is some small example which might help you. It is only about updating an EMA-200 for which the output is chained into a MIN-252 extension.
The EMA-200 first becomes ready eventually and then begins to input values into the MIN. This MIN eventually becomes ready also and then I plot its values.
So such chaining should work. It seems like you tried it and it did not but then, I see two possible reasons:
1- For some reason, your updates were not properly happening when you tested.
2- Your updates were ok but for some reason, your test did not update the indicators with enough data to first make slow ready and then also make MIN ready… So MIN stayed at 0.0 and not ready.
See backtest.
Fred
Log Up
Hi Fred, Thanks for the backtest. yes I do believe it maybe the case 2, as 200 moving average will need 200 bars for it to be ready and MIN indicator will need further 200(total startTime + 400 bar data) periods of 200 moving average data, it maybe the case that I did not have sufficient timespan. Thanks for help :)
Log Up
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!