Back

Yesterday High from 5-min Intraday Data

I wanted to share an algorithm where you can generate yesterday (9:30am - 4:00pm) High from 5-min 24hr data. I used Math.Max method (introduced earlier to me by Alexandre Catarino) and Rolling Windows.

1st you find intraday High between those hours; then you make an assumption that intraday High up to 4pm is that day's High. Lastly you place those 'intraday Highs up to 4pm' into a RollingWindow.

RollingWindow[1] is Yesterday's High. RollingWindow[2] is Day Before Yesterday High.

Update Backtest








You could reset _todayMax to a non-positive number (less or equal to zero), since financial assets cannot have non-positive price. _todayMax = 1 works for ES, but what if we want to us this logic to a penny stock?
Also, please consider using Schedule Events wherever it is possible. E.g.:

// In Initialize
Schedule.On(
DateRules.EveryDay(_symbol),
TimeRules.At(16, 0), () =>
{
dayHighHistory.Add(_todayMax);
});

 

0

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.


Thank you for your comment, again.

I adjusted my algorithm according to your suggestions. Also, now RollingWindow[0] is Yesterday's High, if you are looking for Yesterday High during Market hours before 4pm today.

0


-no value-
0

-no value-
0

Update Backtest





0

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.


Loading...

This discussion is closed