Beispiel #1
0
        /// <summary>
        /// Получает индекс первой свечи с учетом скрола.
        /// </summary>
        /// <param name="timeFrame">Тайм-фрейм</param>
        /// <returns></returns>
        private int GetIndexFirstCandle(CandleLib.CandleCollection timeFrame)
        {
            hScrollGraphic.GuiAsync(() =>
            {
                hScrollGraphic.Minimum = 0;
                if (hScrollGraphic.Maximum == hScrollGraphic.Value)
                {
                    hScrollGraphic.Maximum = timeFrame.Count - this.CountCandleInGraphic;
                    hScrollGraphic.Value   = hScrollGraphic.Maximum;
                }
                else
                {
                    hScrollGraphic.Maximum = timeFrame.Count - this.CountCandleInGraphic;
                }
            });
            int index = hScrollGraphic.Maximum - hScrollGraphic.Value;

            return(index);
        }
        public void Create()
        {
            MutexCollectionCandles.WaitOne();
            this.CollectionTimeFrames.Add(new CandleLib.CandleCollection(1));
            this.CollectionTimeFrames.Last().OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
            };

            this.CollectionTimeFrames.Add(new CandleLib.CandleCollection(2));
            this.CollectionTimeFrames.Last().OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
            };

            this.CollectionTimeFrames.Add(new CandleLib.CandleCollection(3));
            this.CollectionTimeFrames.Last().OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
            };

            var tf = new CandleLib.CandleCollection(5);

            tf.ControlTrades = true;
            this.CollectionTimeFrames.Add(tf);
            tf.OnDeleteExtra += (delCandle) =>
            {
                if (this.IndexWriteCandle > 0)
                {
                    this.IndexWriteCandle--;
                }
            };
            tf.OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
                this.SaveCharts();
            };


            this.CollectionTimeFrames.Add(new CandleLib.CandleCollection(15));
            this.CollectionTimeFrames.Last().OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
            };

            this.CollectionTimeFrames.Add(new CandleLib.CandleCollection(30));
            this.CollectionTimeFrames.Last().OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
            };

            this.CollectionTimeFrames.Add(new CandleLib.CandleCollection(60));
            tf              = this.CollectionTimeFrames.Last();
            tf.OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
            };
            tf.OnNewOldCandle += (tframe, candle) => { this.SaveCharts(); };

            this.CollectionTimeFrames.Add(new CandleLib.CandleCollection(240));
            this.CollectionTimeFrames.Last().OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
            };

            //this.CollectionTimeFrames.Add(new CANDLE.CandleCollection(720));
            this.CollectionTimeFrames.Add(new CandleLib.CandleCollection(1440));
            this.CollectionTimeFrames.Last().OnNewCandle += (tframe, candle) =>
            {
                if (!this.OnNewCandle.IsNull())
                {
                    this.OnNewCandle(tframe, candle);
                }
            };

            this.LoadCharts();
            MutexCollectionCandles.ReleaseMutex();
        }