Пример #1
0
        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();
        }
Пример #2
0
        public void RefreshM5Candle(double CurrentAsk, bool IsCurrentAskValid, double CurrentBid, bool IsCurrentBidValid, DateTime CurrentPriceDateTime)
        {
            if (CurrentPriceDateTime >= m_currentm5candle.CandleEndTime)
            {
                m_currentm5candle = new M5Candle();

                m_m5candlefirstprice = true;

                m_currentm5candle.CandleStartTime = new DateTime(CurrentPriceDateTime.Year, CurrentPriceDateTime.Month, CurrentPriceDateTime.Day, CurrentPriceDateTime.Hour, Convert.ToInt16(CurrentPriceDateTime.Minute / 5 * 5), 0, 0);

                m_currentm5candle.CandleEndTime = m_currentm5candle.CandleStartTime.AddMinutes(5);
            }

            m_currentm5candle.RefreshCandle(CurrentAsk, IsCurrentAskValid, CurrentBid, IsCurrentBidValid, CurrentPriceDateTime, m_m5candlefirstprice);

            if (IsCurrentAskValid == true)
            {
                m_m5candlefirstprice = false;
            }

            // update list item
            M5CandlesList[Convert.ToInt16(CurrentPriceDateTime.Minute / 5)] = m_currentm5candle;
        }