For clarity, I want the previous bar to close at the next bar's open - not the next bar to open at the prior bar's close.
I've tried modifying the OnDataPoint in the MinuteBarsType class as follows, but it doesn't look right based on what I'm trying to do.
Can anyone help? I've been stuck at this for a few days.
Thanks.
protected override void OnDataPoint(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isBar, double bid, double ask) { if (SessionIterator == null) SessionIterator = new SessionIterator(bars); var isNewSession = SessionIterator.IsNewSession(time: time, includesEndTimeStamp: isBar); if (isNewSession) { SessionIterator.GetNextSession(timeLocal: time, includesEndTimeStamp: isBar); } if (bars.Count == 0 || (bars.IsResetOnNewTradingDay && isNewSession)) AddBar(bars, open, high, low, close, TimeToBarTime(bars, time, isBar), volume); else if (!isBar && time < bars.LastBarTime) UpdateBar(bars, high, low, close, bars.LastBarTime, volume); else if (isBar && time <= bars.LastBarTime) UpdateBar(bars, high, low, close, bars.LastBarTime, volume); else { time = TimeToBarTime(bars, time, isBar); UpdateBar(bars, high, low, close, bars.LastBarTime, volume); var priorClose = bars.GetClose(bars.Count - 1); AddBar(bars, priorClose, high, low, close, time, volume); } }
Comment