public Candles() { // initialize M1 Candles list for (int i = 0; i < 60; i++) { M1CandlesList.Add(new M1Candle()); } // initialize M5 Candles list for (int i = 0; i < 12; i++) { M5CandlesList.Add(new M5Candle()); } m_currentm1candle = new M1Candle(); m_currentm5candle = new M5Candle(); }
public void RefreshM1Candle(double CurrentAsk, bool IsCurrentAskValid, double CurrentBid, bool IsCurrentBidValid, DateTime CurrentPriceDateTime) { if (CurrentPriceDateTime >= m_currentm1candle.CandleEndTime) { m_currentm1candle = new M1Candle(); m_m1candlefirstprice = true; m_currentm1candle.CandleStartTime = new DateTime(CurrentPriceDateTime.Year, CurrentPriceDateTime.Month, CurrentPriceDateTime.Day, CurrentPriceDateTime.Hour, CurrentPriceDateTime.Minute, 0, 0); m_currentm1candle.CandleEndTime = m_currentm1candle.CandleStartTime.AddMinutes(1); } m_currentm1candle.RefreshCandle(CurrentAsk, IsCurrentAskValid, CurrentBid, IsCurrentBidValid, CurrentPriceDateTime, m_m1candlefirstprice); m_m1candlefirstprice = false; // update list item M1CandlesList[Convert.ToInt16(CurrentPriceDateTime.Minute / 1)] = m_currentm1candle; }