protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { if (Bars == null || ChartControl == null) return; int barPaintWidth = Math.Max(3, 1 + 2 * ((int)ChartControl.BarWidth - 1) + 2 * shadowWidth); for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++) { if (idx - Displacement < 0 || idx - Displacement >= BarsArray[0].Count || ( idx - Displacement < BarsRequiredToPlot)) continue; double valH = HAHigh.GetValueAt(idx); double valL = HALow.GetValueAt(idx); double valC = HAClose.GetValueAt(idx); double valO = HAOpen.GetValueAt(idx); int x = chartControl.GetXByBarIndex(ChartBars, idx); //was chartControl.BarsArray[0] int y1 = chartScale.GetYByValue(valO); int y2 = chartScale.GetYByValue(valH); int y3 = chartScale.GetYByValue(valL); int y4 = chartScale.GetYByValue(valC); SharpDX.Direct2D1.Brush shadowColordx = shadowColor.ToDxBrush(RenderTarget); // prepare for the color to use var xy2 = new Vector2(x, y2); var xy3 = new Vector2(x, y3); RenderTarget.DrawLine(xy2, xy3, shadowColordx, shadowWidth); if (y4 == y1) RenderTarget.DrawLine( new Vector2( x - barPaintWidth / 2, y1), new Vector2( x + barPaintWidth / 2, y1), shadowColordx, shadowWidth); else { if (y4 > y1) { SharpDX.Direct2D1.Brush barColorDowndx = barColorDown.ToDxBrush(RenderTarget); // prepare for the color to use RenderTarget.FillRectangle( new RectangleF(x - barPaintWidth / 2, y1, barPaintWidth, y4 - y1), barColorDowndx); barColorDowndx.Dispose(); } else { SharpDX.Direct2D1.Brush barColorUpdx = barColorUp.ToDxBrush(RenderTarget); // prepare for the color to use RenderTarget.FillRectangle( new RectangleF(x - barPaintWidth / 2, y4, barPaintWidth, y1 - y4),barColorUpdx); barColorUpdx.Dispose(); } RenderTarget.DrawRectangle( new RectangleF( x - barPaintWidth / 2 + (float)shadowWidth / 2, Math.Min(y4, y1), barPaintWidth - (float)shadowWidth, Math.Abs(y4 - y1)), shadowColordx, shadowWidth); } shadowColordx.Dispose(); } }
- https://ninjatrader.com/support/help..._rendering.htm
- See "SharpDX Vectors and Charting Coordinates"
- https://ninjatrader.com/support/help...oordinates.htm
Comment