Trying to create SMA-40 from intraday 5-min data. The data includes extended hours. I would like SMA-40 to be formed from yesterday's and today's regular sessions' data, excluding overnight hours. So far, I have been unsuccessful not to include hours from 16:00 pm to 9:30 am.
See my code. I would appreciate any advice.
Boris Sachakov
I found a solution to the above problem. I created another class for my data and excluded the overnight hours by the following code inside of BaseDate Reader:
if (cmBar.Time.TimeOfDay < new TimeSpan(9, 30, 00) || cmBar.Time.TimeOfDay > new TimeSpan(16, 10, 00)) { return null; }
Now I have 2 classes that hold the data: 1st - original, 24hrs data; and 2nd - data excluding overnight hours. After that, I had to create another OnData method, that passed the data from newly created class, specifically for SMA.
See the algorithm.
Anne-Mirthe Stam
Boris Sachakov
Anne
Thank you for your great and timely advice. I just began thinking how cumbersome my algorithms are beginning to look. Even to myself, and I wrote them. Readability is definitely very important .
Boris Sachakov
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!