/// <summary> /// This function will be called before removing /// </summary> public override void Complete() { var grafico = CurrentChart.GetChartControl(); grafico.MouseMove -= ProcessMouseMove; grafico.MouseWheel -= ProcessMouseMove; }
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); } }
/// <summary> /// Shows previous chart. /// </summary> private void ShowPreviousChart() { _currentChartNumber--; if (_currentChartNumber < 0) { _currentChartNumber = TableReport.Length - 1; } CurrentChart.Parent = this; CurrentChart.InitChart(TableReport[_currentChartNumber]); CurrentChart.Invalidate(); }
/// <summary> /// Shows next chart. /// </summary> private void ShowNextChart() { _currentChartNumber++; if (_currentChartNumber >= TableReport.Length) { _currentChartNumber = 0; } CurrentChart.Parent = this; CurrentChart.InitChart(TableReport[_currentChartNumber]); CurrentChart.Invalidate(); }
/// <summary> /// This function will be called after creating /// </summary> public override void Init() { // Inicialização da linha rapida SMA10 = Indicators.iMA(CurrentData, LineFastPeriod, 0); // 2=SMMA MAMode TMA10_ = Indicators.iMA((x) => { return(SMA10.GetValue(0, x)); }, LineFastPeriod, 0); // Inicialização da linha media SMA20 = Indicators.iMA(CurrentData, LineMedPeriod, 0); // 2=SMMA MAMode TMA20_ = Indicators.iMA((x) => { return(SMA20.GetValue(0, x)); }, LineMedPeriod, 0); // Inicialização da linha lenta SMA200 = Indicators.iMA(CurrentData, LineLowPeriod, 0); // 2=SMMA MAMode TMA200_ = Indicators.iMA((x) => { return(SMA200.GetValue(0, x)); }, LineLowPeriod, 0); // Inicializacao dos controles das cores dos candles candle = CurrentData as BarData; _markers = new List <Marker>(); var grafico = CurrentChart.GetChartControl(); grafico.MouseMove += ProcessMouseMove; grafico.MouseWheel += ProcessMouseMove; }
void ProcessMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { CurrentChart.Refresh(); }