public TimeframeItem(Timeframes tf) { this.Tf = tf; string[] names = TfHelper.GetTimeframeNames(tf); this.ShortName = names[0]; this.Name = names[1]; }
public Bar(DateTime time, Timeframes tf) : this() { var dates = TfHelper.GetDates(time, tf); this.Time = dates[0]; this.NextBarTime = dates[1]; }
/// <summary> /// Add new tick to BarRow. /// BarRow automatically creates new bars. /// </summary> /// <param name="time"></param> /// <param name="price"></param> /// <param name="count"></param> public void AddTick(DateTime time, decimal price, long count) { if (Timeframe == Timeframes.Tick) { _curBar = new Bar(time, time, price, price, price, price, count); CloseBar(); } else { if (_isNewBar) { DateTime[] bds = TfHelper.GetDates(time, Timeframe); _curBar = new Bar(bds[0], bds[1], price, price, price, price, count); _nextBarTime = bds[1]; _isNewBar = false; _bars.Add(_curBar); _timeline.Add(_curBar.Time, Timeframe); RaiseOnChangeBar(_bars.Count - 1); } else { if (time < _nextBarTime) { _curBar.Close = price; if (_curBar.High < price) { _curBar.High = price; } if (_curBar.Low > price) { _curBar.Low = price; } _curBar.Volume += count; RaiseOnChangeBar(_bars.Count - 1); } else { CloseBar(); DateTime[] bds = TfHelper.GetDates(time, Timeframe); _curBar = new Bar(bds[0], bds[1], price, price, price, price, count); _nextBarTime = bds[1]; _bars.Add(_curBar); _timeline.Add(_curBar.Time, Timeframe); RaiseOnChangeBar(_bars.Count - 1); } } } }
/// <summary> /// Add new time interval. /// </summary> /// <param name="date">Start time</param> /// <param name="tf">Timeframe</param> public void Add(DateTime date, Timeframes tf) { DateTime[] dts = TfHelper.GetDates(date, tf); _dates.Add(new BarDate(dts[0], dts[1])); }
public HistoryProviderTimeframe(Timeframes tf) { this.tf = tf; names = TfHelper.GetTimeframeNames(tf); }