Example #1
0
        /// <summary>
        /// Рисует блок состоящий из нескольких свечей
        /// </summary>
        /// <param name="prepHorV"></param>
        /// <param name="max"></param>
        /// <param name="countInBlock"></param>
        private void PaintOneBlock(PrepareHorVol prepHorV, Chart max, int countInBlock)
        {
            var canvas        = Panel.GetGraphics;
            var canvasOnlyVol = PanelVolume.GetGraphics;

            if (prepHorV.RectBlock.Width >= MIN_WIDTH_FOR_LAYBORDER)
            {
                //рисует прямоугольник выделяющий период
                var rectVol = new RectDraw();
                rectVol.ColorFill   = ColorLayVol;
                rectVol.ColorBorder = ColorLayBorder;
                rectVol.Paint(canvas, prepHorV.RectBlock.X, prepHorV.RectBlock.Y,
                              prepHorV.RectBlock.Width, prepHorV.RectBlock.Height);

                var textMax = new TextDraw();
                textMax.Color = Color.Black;
                var text = "max:" + prepHorV.MaxVol.ToString();
                var size = textMax.GetSizeText(canvas, text);
                textMax.Paint(canvas, text, prepHorV.RectBlock.X, prepHorV.RectBlock.Y - size.Height);
            }

            prepHorV.HorVolumes.ToArray().ForEach <ChartFull>((hv) =>
            {
                this.PaintLineHVol(canvas, prepHorV.RectBlock, max, new Chart(), hv);
                if (PaintOnlyFirstBlock)
                {
                    this.PaintLineHVol(canvasOnlyVol, PanelVolume.Rect.Rectangle, max, new Chart(), hv, Color.Blue);
                }
            });
        }
Example #2
0
        /// <summary>
        /// Рисует уровень ввиде свободного прямоугольника
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="lev"></param>
        /// <param name="widthLine"></param>
        private void PaintRectangleLevel(Graphics g, Rectangle rect, DoubleLevel lev, float widthLine = 1)
        {
            int yTop = GMath.GetCoordinate(rect.Height, Panel.Params.MaxPrice, Panel.Params.MinPrice, lev.Top);
            int yBot = GMath.GetCoordinate(rect.Height, Panel.Params.MaxPrice, Panel.Params.MinPrice, lev.Bottom);

            if (yBot < 0 && yTop > 0)
            {
                yBot = rect.Y + rect.Height;
            }
            if (yTop < 0 && yBot > 0)
            {
                yTop = rect.Y;
            }

            var height = yBot - yTop;

            if (height <= 0)
            {
                return;
            }
            var rectLev = new RectDraw();

            rectLev.ColorBorder = Color.FromArgb(100, Color.Black);
            rectLev.ColorFill   = Color.FromArgb(40, Color.Blue);
            rectLev.WidthBorder = widthLine;
            rectLev.Paint(g, rect.X, yTop, rect.Width, height);

            var middleLine = new Line();

            middleLine.Width = 1;
            middleLine.Style = System.Drawing.Drawing2D.DashStyle.Dot;
            middleLine.Paint(g, new PointF(rect.X, yTop + height / 2), new PointF(rect.X + rect.Width, yTop + height / 2),
                             Color.FromArgb(100, Color.Black));

            var topText    = new TextDraw();
            var dataText   = topText.GetSizeText(g, lev.Top.ToString());
            int HeightText = (int)dataText.Height;

            if (height > HeightText * 3 && rect.Width > dataText.Width)
            {
                topText.Paint(g, lev.Top.ToString(), rect.X, yTop);
                topText.Paint(g, lev.Bottom.ToString(), rect.X, yBot - HeightText);
            }
        }
Example #3
0
        public override void FastUpdate()
        {
            Panel.Clear();
            if (!IsEnable())
            {
                return;
            }
            if (ListTrades.NotIsNull() && ListTrades.Count() > 0)
            {
                var canvas = Panel.GetGraphics;
                //Устанавливаем первую уоординату + смещение
                float XlastTrade = Panel.Rect.Width - 40;
                var   textVol    = new TextDraw();
                textVol.SetFontSize(6);
                textVol.Color = Color.Black;

                foreach (var trade in ListTrades)
                {
                    int   width  = 4;
                    int   Height = 4;
                    SizeF sizeText;
                    float xPlusText = 0;
                    float yPlusText = 0;
                    if (MinVolumeShow <= trade.Volume)
                    {
                        sizeText  = textVol.GetSizeText(canvas, trade.Volume.ToString());
                        width     = Height = (int)(sizeText.Width * 2);
                        xPlusText = (width - sizeText.Width) / 2;
                        yPlusText = (Height - sizeText.Height) / 2;
                    }
                    XlastTrade = XlastTrade - width;

                    float yPrice      = (float)GetYByPrice(trade.Price);
                    var   rect        = new RectDraw();
                    var   colorCandle = trade.Direction == OrderDirection.Buy ? Color.LightGreen : Color.LightCoral;
                    var   colorBorder = Color.Black;
                    rect.Paint(canvas, XlastTrade, yPrice - Height / 2, width, Height, colorBorder, colorCandle);

                    if (MinVolumeShow <= trade.Volume)
                    {
                        textVol.Paint(canvas, trade.Volume.ToString(),
                                      XlastTrade + xPlusText, (yPrice - Height / 2) + yPlusText);
                    }
                }
            }
        }
Example #4
0
        /// <summary>Отрисовка перекрестья</summary>
        /// <param name="coord"></param>
        public void PaintCrossLines(Point coord, GCandles.CandleInfo candle)
        {
            Panel.Clear();
            var    canvas = Panel.GetGraphics;
            string time   = "";

            Data = new DataCross();
            if (candle.NotIsNull())
            {
                Data.Candle = candle;
                Data.Time   = Data.Candle.Candle.Time;
                string d    = Data.Time.Day.ToString();
                string m    = Data.Time.Month.ToString();
                string y    = Data.Time.Year.ToString();
                string min  = Data.Time.Minute.ToString();
                string hour = Data.Time.Hour.ToString();
                time = (d.Length < 2 ? '0' + d : d) + "." + (m.Length < 2 ? '0' + m : m) + "." + y + " " +
                       (hour.Length < 2 ? '0' + hour : hour) + ":" + (min.Length < 2 ? '0' + min : min);
            }
            Data.Price = GMath.GetValueFromCoordinate(this.HeightForPrice, Panel.Params.MaxPrice, Panel.Params.MinPrice, coord.Y, Panel.Params.CountFloat);

            var lineVer = new VerLine();

            lineVer.ColorLine = lineVer.ColorText = Color.Black;
            lineVer.WidthLine = 1;
            lineVer.FillText  = true;
            lineVer.Paint(canvas, time, new Point(coord.X, 0), new Point(coord.X, Panel.Rect.Height));
            Data.Point.X = coord.X;

            var horLine = new HorLine();

            horLine.ColorLine = horLine.ColorText = Color.Black;
            horLine.FillText  = true;
            horLine.Paint(canvas, Panel.Rect.Rectangle, coord.Y, Data.Price.ToString(), Panel.Params.MaxPrice, Panel.Params.MinPrice);
            Data.Point.Y = coord.Y;

            var priceText          = new TextDraw();
            var TextAppendByCandle = "";

            //Данные по свечи в углу
            if (Data.Candle.NotIsNull())
            {
                priceText.Color = Color.Black;
                priceText.SetFontSize(8);
                priceText.Paint(canvas, "T: " + time + "\r\n" +
                                "O: " + Data.Candle.Candle.Open.ToString() + "\r\n" +
                                "H: " + Data.Candle.Candle.High.ToString() + "\r\n" +
                                "L: " + Data.Candle.Candle.Low.ToString() + "\r\n" +
                                "C: " + Data.Candle.Candle.Close.ToString() + "\r\n" +
                                "V: " + Data.Candle.Candle.Volume.ToString() + "\r\n"
                                , 0, 0);
                TextAppendByCandle = "Vol:" + Data.Candle.Candle.Volume;
            }

            //Текщие данные по цене и времени
            priceText.Color = Color.Black;
            priceText.SetFontSize(8);
            priceText.Paint(canvas, Data.Price.ToString() + "\r\n"
                            + time + "\r\n"
                            + TextAppendByCandle
                            , coord.X + 10, coord.Y + 20);
        }
Example #5
0
        public void PaintHorVolByPeriodCandleDelta(bool alwaysUpdate = false, bool delta = false, long limitBorder = 0)
        {
            lock (_lockPaint)
            {
                if (PrepDataHorVol.IsNull())
                {
                    return;
                }
                if (activeCandle1.IsNull() || activeCandle2.IsNull())
                {
                    return;
                }

                Panel.Clear();
                PanelVolume.Clear();
                if (!CreateBlockHorVolume())
                {
                    return;
                }

                var canvas        = Panel.GetGraphics;
                var canvasOnlyVol = PanelVolume.GetGraphics;

                var countCandleInVol = PrepDataHorVol.index1 - PrepDataHorVol.index2 + 1;
                var xLineBorder      = activeCandle2.dataCandle.Body.X + activeCandle2.dataCandle.Body.Width;

                RectangleF rectPaint = new RectangleF();
                rectPaint.X     = activeCandle1.dataCandle.Body.X;
                rectPaint.Width = xLineBorder - activeCandle1.dataCandle.Body.X;
                rectPaint.Width = rectPaint.Width < 40 ? 40 : rectPaint.Width;

                rectPaint.Y      = activeCandle1.dataCandle.TailCoord.Low.Y;
                rectPaint.Height = 0;

                rectPaint.Y      = rectPaint.Y - 13;
                rectPaint.Height = rectPaint.Height + 13;
                //рисует прямоугольник выделяющий период
                var rectVol = new RectDraw();
                rectVol.ColorFill   = ColorLayVol;
                rectVol.ColorBorder = ColorLayBorder;
                rectVol.Paint(canvas, rectPaint.X, Panel.Rect.Y, rectPaint.Width, Panel.Rect.Height);

                //Получяаем максимальный гор. объем в свече или наборе свечей
                PrepDataHorVol.HorVolumes.ToArray().ForEach <ChartFull>((hv) =>
                {
                    PaintLineHVol(canvas, rectPaint, PrepDataHorVol.MaxElem, new Chart(), hv);
                    if (delta)
                    {
                        Chart maxDelta, minDelta = null;
                        if (limitBorder > 0)
                        {
                            maxDelta = new Chart()
                            {
                                Price  = PrepDataHorVol.MaxDeltaElem.Price,
                                Volume = PrepDataHorVol.MaxDeltaElem.Volume > limitBorder ? PrepDataHorVol.MaxDeltaElem.Volume : limitBorder
                            };
                            minDelta = new Chart()
                            {
                                Price  = PrepDataHorVol.MinDeltaElem.Price,
                                Volume = PrepDataHorVol.MinDeltaElem.Volume < limitBorder * -1 ? PrepDataHorVol.MinDeltaElem.Volume : limitBorder * -1
                            };
                        }
                        else
                        {
                            maxDelta = PrepDataHorVol.MaxDeltaElem;
                            minDelta = PrepDataHorVol.MinDeltaElem;
                        }
                        PaintLineHVol(canvasOnlyVol, PanelVolume.Rect.Rectangle, maxDelta, minDelta, hv, null, true);
                        var d = hv.VolBuy - hv.VolSell;
                        if (d > 0)
                        {
                            PrepDataHorVol.SumDeltaBuy += d;
                        }
                        else
                        {
                            PrepDataHorVol.SumDeltaSell += d * -1;
                        }
                    }
                    else
                    {
                        PaintLineHVol(canvasOnlyVol, PanelVolume.Rect.Rectangle, PrepDataHorVol.MaxElem, new Chart(), hv);
                    }
                    PrepDataHorVol.SumBuyVol  += hv.VolBuy;
                    PrepDataHorVol.SumSellVol += hv.VolSell;
                });

                var textMax = new TextDraw();
                textMax.Color = Color.Black;
                textMax.Paint(canvas,
                              "V:" + (PrepDataHorVol.SumBuyVol + PrepDataHorVol.SumSellVol).ToString() + "\r\n"
                              + "D:" + (PrepDataHorVol.SumBuyVol - PrepDataHorVol.SumSellVol).ToString() + "\r\n"
                              + "max:" + PrepDataHorVol.MaxVol.ToString() + "\r\n"
                              + "p:" + PrepDataHorVol.MaxElem.Price.ToString(),
                              rectPaint.X, Panel.Rect.Y);
                if (delta)
                {
                    textMax.Paint(canvasOnlyVol,
                                  "max: " + PrepDataHorVol.MinDeltaElem.Volume.ToString() + "/" + PrepDataHorVol.MaxDeltaElem.Volume.ToString() + "\r\n" +
                                  "sum: " + PrepDataHorVol.SumDeltaSell.ToString() + "/" + PrepDataHorVol.SumDeltaBuy.ToString() + "\r\n"
                                  ,
                                  this.RectForDelta.X, this.RectForDelta.Y);
                }
                else
                {
                    textMax.Paint(canvasOnlyVol,
                                  "max: " + PrepDataHorVol.MaxElem.Volume.ToString() + "\r\n" +
                                  "sum: " + (PrepDataHorVol.SumSellVol + PrepDataHorVol.SumBuyVol).ToString() + "\r\n" +
                                  "sum S/B: " + PrepDataHorVol.SumSellVol.ToString() + "/" + PrepDataHorVol.SumBuyVol.ToString() + "\r\n"
                                  ,
                                  this.RectForDelta.X, this.RectForDelta.Y);
                }
            }
        }