I want to print certain calculations beside the high, low and close of the current candle. and previous candle on the chart.
I was looking at a number of examples that use chartScale.GetYByValue. I have checked the values that I'm entering in and they are matching the y tick value displayed. However the y that is returned is an extremely large negative number so my values aren't displayed. If I override and set y=100 for instance my numbers then start displaying on the screen obviously at a different location.
Is it possible to tell me what I may be doing wrong with the below code. I've attached the full code as well if that helps.
I'm using version 8.0.27.1 64-bit
protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { base.OnRender(chartControl, chartScale); if (CurrentBar < 1) return; TextFormat textFormat = chartControl.Properties.LabelFont.ToDirectWriteTextFormat(); SharpDX.Direct2D1.Brush textBrushDx = TextBrush.ToDxBrush(RenderTarget); ChartPanel panel = chartControl.ChartPanels[ChartPanel.PanelIndex]; // Define the parameters int fontSize = 10; Brush textBrush = Brushes.White; double boxWidth = 50; double boxHeight = 30; var lastBarX = chartControl.GetXByBarIndex(ChartBars, ChartBars.ToIndex); var secondLastBarX = chartControl.GetXByBarIndex(ChartBars, ChartBars.ToIndex - 1); double high = High[0]; double low = Low[0]; var high0_Y = chartScale.GetYByValue(high); var low0_Y = chartScale.GetYByValue(low); int yByValue = chartScale.GetYByValue(Bars.GetClose(Bars.Count - 1)); //double boxX = chartControl.Bounds.Right - boxWidth - 10; //double boxY1 = chartScale.GetYByValue(CurrentBar - 1) - (boxHeight / 2); //double boxY2 = chartScale.GetYByValue(CurrentBar) - (boxHeight / 2); // Draw pivot text System.Windows.Point startPoint = new System.Windows.Point(lastBarX, yByValue); TextLayout textLayout = new TextLayout(Globals.DirectWriteFactory, range1.ToString("0.0"), textFormat, ChartPanel.W, textFormat.FontSize); RenderTarget.DrawTextLayout(startPoint.ToVector2(), textLayout, textBrushDx); }
Comment