Example #1
0
        protected void InitLoopsEachCandle()
        {
            Candels.OnEachCandle += (index, candle, count) =>
            {
                //Первая свеча(актуальная)
                if (index == 0)
                {
                    Volumes.CollectionLevels.Clear();
                    Volumes.Panel.Clear();
                    Volumes.ResetMinMax();
                    Volumes.Min = 0;
                }

                //Обработка свечей которые будут рисоваться
                if (index < Candels.CountPaintCandle)
                {
                    //Объемы
                    Volumes.CollectionLevels.Insert(index, new Chart()
                    {
                        Volume = candle.Volume
                    });
                    if (Volumes.Max < candle.Volume)
                    {
                        Volumes.Max = candle.Volume;
                    }
                }

                Indicators.ForEach((ind) =>
                {
                    if (ind is Indicator)
                    {
                        var indicator = (Indicator)ind;
                        indicator.InitStartIndicator(() =>
                        {
                            indicator.CountVisibleCandle = CountVisibleCandles;
                            indicator.CountAllCandle     = count;
                            indicator.CurrentTimeFrame   = Candels.CurrentTimeFrame;
                        });
                        indicator.EachCandle(index, candle, count);
                        if (index == count - 1)
                        {
                            indicator.InitEndIndicator(() => { });
                        }
                    }
                });

                if (index == count - 1)
                {
                    var step = Volumes.Max * 10 / 100;
                    Volumes.Max += step;
                    Volumes.Min -= step;
                }
            };
            //После отрисованной свечи
            Candels.OnEachPaintedCandle += (dCandle) =>
            {
                if (dCandle.First)
                {
                    Times.BeforePaint();
                }
                //Рисуем временные отметки
                Times.Paint(dCandle);

                if (dCandle.Last)
                {
                }
            };
        }