示例#1
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);
            }
        }
示例#2
0
        public override void NextBar()
        {
            // colocar as cores do grafico padrão igual ao fundo, assim o gráfico não é mostrado
            CurrentChart.BodyBottomColor = CurrentChart.BackgroundBottomColor;
            CurrentChart.BodyUpColor     = CurrentChart.BackgroundBottomColor;



            // mostra o novo candle com o padrão de cores tabajara
            _markers.Insert(0, new Marker(CurrentData.Time(), CurrentData.GetPrice(PriceType.Open)));
        }