Example #1
0
        public override void OnPaintChart(PaintChartEventArgs args)
        {
            base.OnPaintChart(args);

            if (callStrikes == null || putStrikes == null)
            {
                return;
            }

            // Draw call options
            args.Graphics.DrawString($"CALL {callStrikes[0].ExpirationDate.ToShortDateString()}", font, textBrush, 30, 50);
            int textY = 70;

            foreach (var strike in callStrikes)
            {
                double iv = model.IV(strike, OptionPriceType.Ask, 0, 0);
                args.Graphics.DrawString($"Strike: {strike.FormatPrice(strike.StrikePrice)} Ask: {strike.FormatPrice(strike.Ask)} IV: {Math.Round(iv * 100, 2)}% Gamma: {model.Gamma(strike, iv, 0, 0).ToString("N5")}", font, textBrush, 30, textY);
                textY += 20;
            }

            // Draw put options
            args.Graphics.DrawString($"PUT {putStrikes[0].ExpirationDate.ToShortDateString()}", font, textBrush, 400, 50);
            textY = 70;
            foreach (var strike in putStrikes)
            {
                double iv = model.IV(strike, OptionPriceType.Ask, 0, 0);
                args.Graphics.DrawString($"Strike: {strike.FormatPrice(strike.StrikePrice)} Ask: {strike.FormatPrice(strike.Ask)} IV: {Math.Round(iv * 100, 2)}% Gamma: {model.Gamma(strike, iv, 0, 0).ToString("N5")}", font, textBrush, 400, textY);
                textY += 20;
            }
        }
Example #2
0
        public override void OnPaintChart(object sender, PaintChartEventArgs args)
        {
            args.Graphics.SetClip(CurrentChart.MainWindow.WindowRectangle);
            var barWidth = CurrentChart.GetChartPoint(CurrentData.Time(), 0).X - CurrentChart.GetChartPoint(CurrentData.Time(1), 0).X;
            var obj      = new object();

            lock (obj)
            {
                foreach (Marker marker in _markers)
                {
                    if (CurrentChart.GetTimePrice(args.Rectangle.X, args.Rectangle.Y).Time <= marker.TimePosition && CurrentChart.GetTimePrice(args.Rectangle.X + args.Rectangle.Width, args.Rectangle.Y).Time > marker.TimePosition)
                    {
                        // determina a Cor do Candle de acordo com regra "OnQuote" e cores definidas na configuraĆ§Ć£o
                        // CorBarraCompra, CorBarraVenda
                        // Logica para cor da barra
                        // se estiver dentro da tendencia, colore com as CorBarra, e estiver fora da tendencia colore com as CorBarraPadrao
                        // var pen = new Pen(new SolidBrush(marker.side == Side.Sell ? CorBarraVenda : CorBarraCompra), barWidth / 20);  linha original
                        var pen = new Pen(new SolidBrush(marker.side == Side.Sell ? CorBarraVenda : (marker.side == Side.Buy ? CorBarraCompra : CorBarraCompraPadrao)), barWidth / 20);

                        var startPos  = CurrentChart.GetChartPoint(marker.TimePosition, marker.Close >= marker.Open ? marker.Open : marker.Close);
                        var finishPos = CurrentChart.GetChartPoint(marker.TimePosition, marker.Close >= marker.Open ? marker.Close : marker.Open);
                        var height    = Math.Abs(startPos.Y - finishPos.Y + 1);
                        //var rect = new RectangleF(startPos.X + barWidth / 20, finishPos.Y - 1, barWidth - barWidth / 10, height);    original
                        //var rect = new RectangleF(startPos.X + barWidth / 4, finishPos.Y - 1, barWidth-4, height);
                        var rect = new RectangleF(startPos.X + barWidth / 5, finishPos.Y - 1, barWidth - 5, height);

                        args.Graphics.FillRectangle(pen.Brush, rect);
                        var highPos = CurrentChart.GetChartPoint(marker.TimePosition, marker.High);
                        var lowPos  = CurrentChart.GetChartPoint(marker.TimePosition, marker.Low);
                        args.Graphics.DrawLine(pen, new PointF(rect.X + rect.Width / 2, highPos.Y - 1), new PointF(rect.X + rect.Width / 2, lowPos.Y));
                    }
                }
                base.OnPaintChart(sender, args);
            }
        }
Example #3
0
        public override void OnPaintChart(PaintChartEventArgs args)
        {
            base.OnPaintChart(args);

            // First point not specified
            if (this.lastMouseDownPoint == Point.Empty)
            {
                return;
            }

            // Draw line between point where we clicked mouse and current mouse position
            Graphics gr  = args.Graphics;
            Pen      pen = new Pen(Brushes.Orange, 2);

            gr.DrawLine(pen, lastMouseDownPoint, args.MousePosition);
            gr.FillEllipse(Brushes.Orange, lastMouseDownPoint.X - 3, lastMouseDownPoint.Y - 3, 6, 6);
            gr.FillEllipse(Brushes.Orange, args.MousePosition.X - 3, args.MousePosition.Y - 3, 6, 6);

            // Calculate prices from Y coordinate (using CoordinatesConverter)
            double price1          = this.CurrentChart.MainWindow.CoordinatesConverter.GetPrice(lastMouseDownPoint.Y);
            string formattedPrice1 = this.Symbol.FormatPrice(price1);

            double price2          = this.CurrentChart.MainWindow.CoordinatesConverter.GetPrice(args.MousePosition.Y);
            string formattedPrice2 = this.Symbol.FormatPrice(price2);

            double deltaPrice          = price2 - price1;
            string formattedDeltaPrice = this.Symbol.FormatPrice(deltaPrice);

            // Draw required text labels (using absolute coordinates and mouse positions)
            Font font = new Font("Arial", 8, FontStyle.Regular);

            gr.DrawString($"Price 1: {formattedPrice1}", font, Brushes.Orange, args.MousePosition.X + 20, args.MousePosition.Y);
            gr.DrawString($"Price 2: {formattedPrice2}", font, Brushes.Orange, args.MousePosition.X + 20, args.MousePosition.Y + 20);
            gr.DrawString($"Delta price: {formattedDeltaPrice}", font, Brushes.Orange, args.MousePosition.X + 20, args.MousePosition.Y + 40);
        }
        public override void OnPaintChart(object sender, PaintChartEventArgs args)
        {
            if (HistoryDataSeries.Count == 0)
            {
                return;
            }

            //draw circle on min max

            int winNumber = ChartSource.FindWindow(this);
            var winRect   = ChartSource.GetAllWindows()[winNumber].WindowRectangle;

            args.Graphics.SetClip(winRect);

            var leftPoint  = winRect.Location;
            var rightPoint = new Point(leftPoint.X + winRect.Width, leftPoint.Y);

            var leftTime  = ChartSource.GetTimeValue(leftPoint, winNumber).TimeUtc;
            var rightTime = ChartSource.GetTimeValue(rightPoint, winNumber).TimeUtc;

            int leftOffset  = HistoryDataSeries.FindInterval(leftTime);
            int rightOffset = HistoryDataSeries.FindInterval(rightTime);

            if (leftOffset == -1)
            {
                leftOffset = HistoryDataSeries.Count - 1;
            }

            if (rightOffset == -1)
            {
                rightOffset = 0;
            }

            var barWidth = ChartSource.BarsWidth;

            for (int i = rightOffset; i <= leftOffset; i++)
            {
                double val = Lines["MinMax"].GetValue(i);

                if (val == 0)
                {
                    continue;
                }

                var dt    = HistoryDataSeries.GetTimeUtc(i);
                var price = val == 1
                                        ? HistoryDataSeries.GetValue(PriceType.High, i)
                                        : HistoryDataSeries.GetValue(PriceType.Low, i);

                var curPoint = ChartSource.GetChartPoint(new TimeValue(dt, price), winNumber);
                var brush    = val == 1 ? maxBrush : minBrush;

                args.Graphics.FillEllipse(brush, curPoint.X, curPoint.Y - barWidth / 2,
                                          barWidth, barWidth);
            }
        }
Example #5
0
        public override void OnPaintChart(object sender, PaintChartEventArgs args)
        {
            if (curLeftSup != nullPoint && curRightSup != nullPoint)
            {
                var point1 = ChartSource.GetChartPoint(curRightSup, ChartSource.FindWindow(this));
                var point2 = ChartSource.GetChartPoint(curLeftSup, ChartSource.FindWindow(this));
                draw_beam(point1, point2, Lines[1].Color, args);
            }

            if (curLeftRes != nullPoint && curRightRes != nullPoint)
            {
                var point1 = ChartSource.GetChartPoint(curRightRes, ChartSource.FindWindow(this));
                var point2 = ChartSource.GetChartPoint(curLeftRes, ChartSource.FindWindow(this));
                draw_beam(point1, point2, Lines[0].Color, args);
            }
        }
Example #6
0
        public override void OnPaintChart(PaintChartEventArgs args)
        {
            base.OnPaintChart(args);

            if (this.CurrentChart == null)
            {
                return;
            }

            Graphics graphics = args.Graphics;

            // Use StringFormat class to center text
            StringFormat stringFormat = new StringFormat()
            {
                LineAlignment = StringAlignment.Center,
                Alignment     = StringAlignment.Center
            };

            var  mainWindow = this.CurrentChart.MainWindow;
            Font font       = new Font("Arial", 10, FontStyle.Bold);

            // Get left and right time from visible part or history
            DateTime leftTime  = mainWindow.CoordinatesConverter.GetTime(mainWindow.ClientRectangle.Left);
            DateTime rightTime = mainWindow.CoordinatesConverter.GetTime(mainWindow.ClientRectangle.Right);

            // Convert left and right time to index of bar
            int leftIndex  = (int)mainWindow.CoordinatesConverter.GetBarIndex(leftTime);
            int rightIndex = (int)Math.Ceiling(mainWindow.CoordinatesConverter.GetBarIndex(rightTime));

            // Process only required (visible on the screen at the moment) range of bars
            for (int i = leftIndex; i <= rightIndex; i++)
            {
                if (i > 0 && i < this.HistoricalData.Count && this.HistoricalData[i, SeekOriginHistory.Begin] is HistoryItemBar bar)
                {
                    bool isBarGrowing = bar.Close > bar.Open;

                    // Calculate coordinates for drawing text. X - middle of the bar. Y - above High or below Low
                    int textXCoord = (int)Math.Round(mainWindow.CoordinatesConverter.GetChartX(bar.TimeLeft) + this.CurrentChart.BarsWidth / 2.0);
                    int textYCoord = (int)Math.Round(isBarGrowing ? (mainWindow.CoordinatesConverter.GetChartY(bar.High) - 20) : (mainWindow.CoordinatesConverter.GetChartY(bar.Low) + 20));

                    graphics.DrawString(isBarGrowing ? "Up" : "Down", font, isBarGrowing ? Brushes.Green : Brushes.Red, textXCoord, textYCoord, stringFormat);
                }
            }
        }
        public override void OnPaintChart(object sender, PaintChartEventArgs args)
        {
            var gr = args.Graphics;

            int winNumber = ChartSource.FindWindow(this);

            if (winNumber != 0)
            {
                using (StringFormat format = new StringFormat())
                {
                    format.LineAlignment = StringAlignment.Center;
                    format.Alignment     = StringAlignment.Center;

                    gr.DrawString("The indicator operates only on the main chart", new Font("Arial", 24), boxBrush, args.Rectangle, format);
                }

                return;
            }
        }
Example #8
0
        public override void OnPaintChart(PaintChartEventArgs args)
        {
            base.OnPaintChart(args);

            Font font = new Font("Arial", 8, FontStyle.Regular);

            // Check if everything is ready to draw volume analysis data
            if (this.hoursHistory == null || this.loadingVolumeAnalysisProgress == null || this.loadingVolumeAnalysisProgress.State != VolumeAnalysisCalculationState.Finished || this.hoursHistory.Count < HOURS_COUNT)
            {
                args.Graphics.DrawString($"Volume analysis data is loading {this.loadingVolumeAnalysisProgress.ProgressPercent}%...", font, Brushes.LightBlue, 30, 50);
                return;
            }

            // Draw volume analysis data
            args.Graphics.DrawString($"Last {HOURS_COUNT} hours volume:", font, Brushes.LightBlue, 30, 50);
            for (int i = 0; i < HOURS_COUNT; i++)
            {
                args.Graphics.DrawString($"{this.hoursHistory[i].TimeLeft.ToShortTimeString()} = {this.Symbol.FormatQuantity(this.hoursHistory[i].VolumeAnalysisData.Total.Volume)}", font, Brushes.LightBlue, 30, 70 + 20 * i);
            }
        }
Example #9
0
        void draw_beam(PointF point1, PointF point2, Color color, PaintChartEventArgs args)
        {
            RectangleF rect = args.Rectangle;

            args.Graphics.SetClip(rect);
            PointF point3;

            PointF[] point_arr1;

            if (point1.X > point2.X)
            {
                var temp = new PointF(point1.X, point1.Y);
                point1 = new PointF(point2.X, point2.Y);
                point2 = new PointF(temp.X, temp.Y);
            }

            point3 = new PointF(Lerp(point1.X, point2.X, rect.Width - (rect.X + point2.X)),
                                Lerp(point1.Y, point2.Y, rect.Width - (rect.X + point2.X)));

            point_arr1 = new PointF[] { point1, point2, point3 };

            args.Graphics.DrawLines(new Pen(color, 2), point_arr1);
        }
Example #10
0
        public override void OnPaintChart(object sender, PaintChartEventArgs args)
        {
            if (HistoryDataSeries.Count == 0)
            {
                return;
            }

            int winNumber = ChartSource.FindWindow(this);
            var winRect   = ChartSource.GetAllWindows()[winNumber].WindowRectangle;

            args.Graphics.SetClip(winRect);

            var leftPoint  = winRect.Location;
            var rightPoint = new Point(leftPoint.X + winRect.Width, leftPoint.Y);

            var leftTime  = ChartSource.GetTimeValue(leftPoint, winNumber).TimeUtc;
            var rightTime = ChartSource.GetTimeValue(rightPoint, winNumber).TimeUtc;

            int leftOffset  = HistoryDataSeries.FindInterval(leftTime);
            int rightOffset = HistoryDataSeries.FindInterval(rightTime);

            if (leftOffset == -1)
            {
                leftOffset = HistoryDataSeries.Count - 1;
            }

            if (rightOffset == -1)
            {
                rightOffset = 0;
            }

            var barWidth = ChartSource.BarsWidth;

            for (int i = rightOffset; i <= leftOffset; i++)
            {
                double open  = Lines["Open"].GetValue(i);
                double high  = Lines["High"].GetValue(i);
                double low   = Lines["Low"].GetValue(i);
                double close = Lines["Close"].GetValue(i);
                var    dt    = HistoryDataSeries.GetTimeUtc(i);

                var openPoint  = ChartSource.GetChartPoint(new TimeValue(dt, open), winNumber);
                var highPoint  = ChartSource.GetChartPoint(new TimeValue(dt, high), winNumber);
                var lowPoint   = ChartSource.GetChartPoint(new TimeValue(dt, low), winNumber);
                var closePoint = ChartSource.GetChartPoint(new TimeValue(dt, close), winNumber);

                var lowerPoint = open < close ? openPoint : closePoint;
                var upperPoint = open > close ? openPoint : closePoint;

                float middlex = lowerPoint.X + barWidth / 2;

                args.Graphics.DrawLine(pen, new PointF(middlex, lowPoint.Y), new PointF(middlex, lowerPoint.Y));
                args.Graphics.DrawLine(pen, new PointF(middlex, highPoint.Y), new PointF(middlex, upperPoint.Y));

                float decimalPart   = barWidth / 10;
                var   leftTopPoint  = new PointF(upperPoint.X + decimalPart, upperPoint.Y);
                var   rightTopPoint = new PointF(upperPoint.X + barWidth - decimalPart, upperPoint.Y);

                var leftBottomPoint  = new PointF(lowerPoint.X + decimalPart, lowerPoint.Y);
                var rightBottomPoint = new PointF(lowerPoint.X + barWidth - decimalPart, lowerPoint.Y);

                args.Graphics.DrawLine(pen, leftTopPoint, rightTopPoint);
                args.Graphics.DrawLine(pen, leftBottomPoint, rightBottomPoint);
                args.Graphics.DrawLine(pen, leftTopPoint, leftBottomPoint);
                args.Graphics.DrawLine(pen, rightTopPoint, rightBottomPoint);
            }
        }
Example #11
0
        public override void OnPaintChart(object sender, PaintChartEventArgs args)
        {
            if (HistoryDataSeries.Count == 0)
            {
                return;
            }

            int winNumber = ChartSource.FindWindow(this);
            var winRect   = ChartSource.GetAllWindows()[winNumber].WindowRectangle;

            args.Graphics.SetClip(winRect);

            var leftPoint  = winRect.Location;
            var rightPoint = new Point(leftPoint.X + winRect.Width, leftPoint.Y);

            var leftTime  = ChartSource.GetTimeValue(leftPoint, winNumber).TimeUtc;
            var rightTime = ChartSource.GetTimeValue(rightPoint, winNumber).TimeUtc;

            int leftOffset  = HistoryDataSeries.FindInterval(leftTime);
            int rightOffset = HistoryDataSeries.FindInterval(rightTime);

            if (leftOffset == -1)
            {
                leftOffset = HistoryDataSeries.Count - 1;
            }

            if (rightOffset == -1)
            {
                rightOffset = 0;
            }

            var barWidth = ChartSource.BarsWidth;

            double previousClose = double.NaN;
            var    previousDt    = DateTime.MinValue;

            for (int i = rightOffset; i <= leftOffset; i++)
            {
                double close = HistoryDataSeries.GetValue(TradeApi.History.PriceType.Close, i);
                var    dt    = HistoryDataSeries.GetTimeUtc(i);
                if (double.IsNaN(previousClose))
                {
                    previousClose = close;
                    previousDt    = dt;
                    continue;
                }

                if (previousDt == dt || Math.Abs((previousClose - close) / close) < _priceChangeLimit / 100)
                {
                    continue;
                }


                var previousClosePoint = ChartSource.GetChartPoint(new TimeValue(previousDt, previousClose), winNumber);
                var nextClosePoint     = ChartSource.GetChartPoint(new TimeValue(dt, close), winNumber);

                args.Graphics.DrawLine(_pen, new PointF(previousClosePoint.X + barWidth / 2, previousClosePoint.Y), new PointF(nextClosePoint.X + barWidth / 2, nextClosePoint.Y));
                previousClose = close;
                previousDt    = dt;
            }
        }
        public override void OnPaintChart(object sender, PaintChartEventArgs args)
        {
            if (!isDrawable)
            {
                return;
            }

            var gr        = args.Graphics;
            var winNumber = ChartSource.FindWindow(this);

            if (winNumber != 0)
            {
                using (StringFormat format = new StringFormat())
                {
                    format.LineAlignment = StringAlignment.Center;
                    format.Alignment     = StringAlignment.Center;

                    gr.DrawString("The indicator operates only on the main chart", new Font("Arial", 24), boxBrush, args.Rectangle, format);
                }
                return;
            }

            var winRect = ChartSource.GetAllWindows()[winNumber].WindowRectangle;

            args.Graphics.SetClip(winRect);

            var leftPoint   = winRect.Location;
            var rightPoint  = new Point(leftPoint.X + winRect.Width, leftPoint.Y);
            var leftTime    = ChartSource.GetTimeValue(leftPoint, winNumber).TimeUtc;
            var rightTime   = ChartSource.GetTimeValue(rightPoint, winNumber).TimeUtc;
            var leftOffset  = HistoryDataSeries.FindInterval(leftTime);
            var rightOffset = HistoryDataSeries.FindInterval(rightTime);

            if (leftOffset == -1)
            {
                leftOffset = HistoryDataSeries.Count - 1;
            }

            if (rightOffset == -1)
            {
                rightOffset = 0;
            }

            List <Exchange>     properExchanges = settings.defaultExchanges;
            List <BoxContainer> listToDraw      = fillBoxes(rightOffset, leftOffset, settings.defaultExchanges, winNumber);

            listToDraw.ForEach(el =>
            {
                var rect = new RectangleF(el.LeftPoint.X, el.LeftPoint.Y, Math.Abs(el.LeftPoint.X - el.RightPoint.X), Math.Abs(el.LeftPoint.Y - el.RightPoint.Y));

                boxPen.DashPattern = new float[] { 2, 2 };
                gr.DrawRectangle(boxPen, rect.X, rect.Y, rect.Width, rect.Height);

                using (Brush activeBrush = new SolidBrush(el.Color)) {
                    gr.FillRectangle(activeBrush, rect);
                }
            });

            var offset = 0;

            listToDraw.ForEach(el =>
            {
                var rect = new RectangleF(el.LeftPoint.X, el.LeftPoint.Y, Math.Abs(el.LeftPoint.X - el.RightPoint.X), Math.Abs(el.LeftPoint.Y - el.RightPoint.Y));
                var midp = Midpoint(rect, offset);

                using (StringFormat format = new StringFormat()) {
                    format.LineAlignment = StringAlignment.Center;
                    format.Alignment     = StringAlignment.Center;

                    gr.DrawString(el.Name, font, boxBrush, midp.X, midp.Y, format);
                }
                offset++;
            });

            var todayDate         = HistoryDataSeries.GetTimeUtc(0).Date;
            var tomorrowDate      = HistoryDataSeries.GetTimeUtc(0).Date.AddDays(1).Date;
            var todayExchanges    = properExchanges.FindAll(x => x.ExchangeDateTimeUTC(todayDate, x.BeginTime) > HistoryDataSeries.GetTimeUtc(0));
            var tomorrowExchanges = properExchanges.FindAll(x => x.ExchangeDateTimeUTC(tomorrowDate, x.BeginTime) > HistoryDataSeries.GetTimeUtc(0));
            var valueTop          = ChartSource.GetTimeValue(new PointF(0, 0), winNumber).Value;
            var valueBottom       = ChartSource.GetTimeValue(new PointF(args.Rectangle.Height, args.Rectangle.Width), winNumber).Value;

            offset = 0;
            todayExchanges.ForEach(el =>
            {
                if (el.IsEnable)
                {
                    var poinTop    = ChartSource.GetChartPoint(new TimeValue(el.ExchangeDateTimeUTC(todayDate, el.BeginTime), valueTop), winNumber);
                    var poinBottom = ChartSource.GetChartPoint(new TimeValue(el.ExchangeDateTimeUTC(todayDate, el.BeginTime), valueBottom), winNumber);

                    gr.DrawLine(boxPen, poinTop, poinBottom);
                    gr.DrawString(el.Name, font, boxBrush, poinTop.X, offset % 2 == 0 ? poinTop.Y : poinTop.Y + 20);
                    offset++;
                }
            });

            offset = 0;
            tomorrowExchanges.ForEach(el =>
            {
                if (el.IsEnable)
                {
                    var poinTop    = ChartSource.GetChartPoint(new TimeValue(el.ExchangeDateTimeUTC(tomorrowDate, el.BeginTime), valueTop), winNumber);
                    var poinBottom = ChartSource.GetChartPoint(new TimeValue(el.ExchangeDateTimeUTC(tomorrowDate, el.BeginTime), valueBottom), winNumber);

                    gr.DrawLine(new Pen(linebrush), poinTop, poinBottom);
                    gr.DrawString(el.Name, font, linebrush, poinTop.X, offset % 2 == 0 ? poinTop.Y + args.Rectangle.Height - 40 : poinTop.Y + args.Rectangle.Height - 60);
                    offset++;
                }
            });
        }
        public override void OnPaintChart(object sender, PaintChartEventArgs args)
        {
            var winNumber = ChartSource.FindWindow(this);
            var winRect   = ChartSource.GetAllWindows()[winNumber].WindowRectangle;

            args.Graphics.SetClip(winRect);

            var leftPoint  = winRect.Location;
            var rightPoint = new Point(leftPoint.X + winRect.Width, leftPoint.Y);

            var leftTime  = ChartSource.GetTimeValue(leftPoint, winNumber).TimeUtc;
            var rightTime = ChartSource.GetTimeValue(rightPoint, winNumber).TimeUtc;

            int leftOffset  = HistoryDataSeries.FindInterval(leftTime);
            int rightOffset = HistoryDataSeries.FindInterval(rightTime);

            if (leftOffset == -1)
            {
                leftOffset = HistoryDataSeries.Count - 1;
            }

            if (rightOffset == -1)
            {
                rightOffset = 0;
            }

            var  barWidth = ChartSource.BarsWidth;
            int  fontSize = barWidth / 3;
            Font drawFont = new Font("Arial", fontSize);

            int counter = 1;

            for (int i = rightOffset; i <= leftOffset; i++)
            {
                double open  = HistoryDataSeries.GetValue(PriceType.Open, i);
                double close = HistoryDataSeries.GetValue(PriceType.Close, i);
                double high  = HistoryDataSeries.GetValue(PriceType.High, i);
                double low   = HistoryDataSeries.GetValue(PriceType.Low, i);
                var    dt    = HistoryDataSeries.GetTimeUtc(i);

                var openPoint  = ChartSource.GetChartPoint(new TimeValue(dt, open), winNumber);
                var closePoint = ChartSource.GetChartPoint(new TimeValue(dt, close), winNumber);
                var highPoint  = ChartSource.GetChartPoint(new TimeValue(dt, high), winNumber);
                var lowPoint   = ChartSource.GetChartPoint(new TimeValue(dt, low), winNumber);

                var lowerPoint = open < close ? openPoint : closePoint;
                var upperPoint = open > close ? openPoint : closePoint;


                var candleBodyRect = new Rectangle((int)upperPoint.X + 6, (int)upperPoint.Y, barWidth - 10, (int)lowerPoint.Y - (int)upperPoint.Y);
                var candleFullRect = new Rectangle((int)highPoint.X, (int)highPoint.Y, barWidth, (int)lowPoint.Y - (int)highPoint.Y);

                string drawString = string.Empty;

                int   x     = 0;
                int   y     = 0;
                float angle = 0;

                switch (counter)
                {
                case 1:
                    //left vertical
                    x          = candleBodyRect.Left - (fontSize + (fontSize / 2)); // from the left edge of the candle body
                    y          = candleFullRect.Bottom;                             // from the bottom of the whole candle
                    angle      = -90;                                               //draw from bottom to top
                    drawString = "left vertical";
                    break;

                case 5:
                    //top horizontal from center
                    x          = candleBodyRect.Left + (candleBodyRect.Width / 2); // from the left edge of the candle body, taking into account the font size
                    y          = candleFullRect.Top - (fontSize + (fontSize / 2)); // from the bottom of the whole candle
                    drawString = "top horizontal";
                    break;

                case 9:
                    //bottom horizontal from left edge of the whole candle
                    x          = candleFullRect.Left;   // from the left edge of the whole candle body
                    y          = candleFullRect.Bottom; // from the bottom of the whole candle
                    drawString = "bottom horizontal";
                    break;

                case 13:
                    //center vertical from top to bootom under the whole candle
                    x          = candleBodyRect.Left + (candleBodyRect.Width / 2) + ((fontSize + (fontSize / 2)) / 2);
                    y          = candleFullRect.Bottom;
                    angle      = 90;//from top to bottom
                    drawString = "bottom center horizontal";
                    break;
                }
                if (++counter > 13)
                {
                    counter = 0;
                }
                if (string.IsNullOrEmpty(drawString))
                {
                    continue;
                }
                if (angle != 0)
                {
                    DrawRotatedTextAt(args.Graphics, angle, drawString, drawFont, drawBrush, x, y);
                }
                else
                {
                    args.Graphics.DrawString(drawString, drawFont, drawBrush, x, y);
                }
            }
        }