Back

Need to find Today's low up to this point

I am using 5-min data and trying to see if the candle I am looking for is making a new low for today up to this point. If the candle is at 10:30am, how can I find what the low of the day up to now has been? Searching through docs and forum, the obvious answer was to use consolidators. But either I am not using them right or something else is wrong, but I am not getting what I need. I only get the lows of each 5-min period of  the day, but not the low of consolidated data. So I can't compare (by using < or >) the low of the candle at 10:30am with prior low so far. Suggestions?

Update Backtest








One solution would be using a variable that we "reset" every day and compare it againt the current Low:

private decimal _todayMin = 99999;

// In OnData
_todayMin = Math.Min(_toadyMin, data.Low);

In order to reset that variable (set it to 99999), we could rely on the Schedule Events:

// In Initialize
Schedule.On(
DateRules.EveryDay(_symbol),
TimeRules.At(9, 30), () =>
{
_todayMin = 99999;
});
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.


Alex,

Thanks for your response. This is exactly what I have been looking for. I just want to add, that I had to put _todayMin into RollingWindows in order to exclude the low of the present period to be able to compare the prior low to the present low.

 

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