Somebody please tell me how to capture the closing price of the first bar of the day (using minute resolution) and remember that price all day, then replace it with the closing price of the first bar for each successive day. data[symbol].Close will capture it, but that gets replaced with each successive bar of the day. There has to be a way of doing it (simple way would be better :), but I haven't found it. Help please, and thank you.
Oran Christian
Michael Handschuh
Oran Christian
Levitikon
private decimal YesterdaysClose { get; set; } public override void OnEndOfDay() { this.YesterdaysClose = Securities["SPY"].Close; }
The only down fall to this is you'll have to ensure a full day has passed before your algorithm can get access to this. To get around this you could 1. Set YesterdaysClose in Initialize maybe. 2. Or, Warmup 1 day. This is probably more reliable.public override void Initialize() { this.SetWarmUp(TimeSpan.FromDays(1)); ... }
And ensure your OnData doesn't process while warming up:public override void OnData(Slice data) { if (this.IsWarmingUp) return;
Oran Christian
Oran Christian
Michael Handschuh
Oran Christian
public override void Initialize ()
, and goes topublic void OnData(TradeBars data).
. It didn't work. I see now, my mistake was that I put it in the right section, but before the "AddSecurity(...)" line. I tried again with it after "AddSecurity(...)" and it works. I read the link you gave above (probably 10 times) and it's still all mud. It uses a lot of words and terms that I don't know what they mean, so I am now trying to learn those meanings so that I can understand the article. This is going to take some time! In the meantime, can you (or someone) please explain to me the difference between "Securities[symbol].Close" and "data[symbol].Close" and when each should be used? I think I hear you saying that it "has to deal with closures", but "closures" is one of those words I am learning the meaning of. For now, can I get a plain English lesson on the two? Thanks to everyone for your patience and help. I hate being a dumb newbie, but we all have to start somewhere!Michael Handschuh
Oran Christian
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!