I'm trying out a strategy where I make use of various indicators to check for overbought and oversold conditions.
My Code is intended to run each day and employs OHLC values and indicator values for the past 3 days.
I have used a rolling window for this purpose.
The data I seem to get in the logs doesnt seem to agree with the actual available data and Low and Close values are always very close.
Can someone please help me out
Mia Alissi
Sure, I can help you with that. The
RollingWindow
in QuantConnect is a fixed-size array that holds trailing data. It's more efficient to useRollingWindow
objects to hold periods of data than to make multiple historical data requests. With aRollingWindow
, you just update the latest data point while aHistory
call fetches all of the data over the period you request.Here is an example of how to create a
RollingWindow
and add data to it:You can also track historical indicator values using a
RollingWindow
. Indicators emit anUpdated
event when they update. To create aRollingWindow
of indicator points, attach an event handler function to theUpdated
member that adds the last value of the indicator to theRollingWindow
. The value is anIndicatorDataPoint
object that represents a piece of data at a specific time.Here is an example of how to do this:
If you're seeing discrepancies in the data, it might be due to how you're accessing the data in the
RollingWindow
. The most recent data is at index 0, the previous data is at index 1, and so on. Here is how you can access the data:If you're still having issues, it would be helpful to see the specific code you're using to access the data in the
RollingWindow
.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.
Atin
here's the code
Â
Mia Alissi
Based on the code you've shared, it seems like you're using the
RollingWindow
correctly. You're initializing theRollingWindow
objects for different indicators and OHLC values, and you're adding data to them in the correct manner.However, the issue you're facing might be related to how you're accessing the data in the
RollingWindow
. Remember thatRollingWindow
objects operate on a first-in, first-out process to allow for reverse list access semantics. This means that index 0 refers to the most recent item in the window and the largest index refers to the last item in the window.Here is how you can access the data:
In your code, you're accessing the data correctly. For example,
self.ohlc_window[0].Low
correctly refers to the most recent low price.If the Low and Close values are always very close, it might be due to the nature of the data itself. You might want to check the raw data to see if this is the case.
If you're still facing issues, please share more details or the specific part of the code that's causing the problem.
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.
Atin
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!