the task of drawing an ellipse in the form of a ball, at the closing price of the bar of the filtered volume
if (BarsInProgress == 1)
{
if (Volume[0] > 500)
{
VolBar = Close[0];
}
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++)
{
float x = chartControl.GetXByBarIndex(ChartBars, idx);
float y = chartScale.GetYByValue(VolBar);
//Line
RenderTarget.DrawLine(new Vector2(x + 100, y), new Vector2(x, y), new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.Red), 4);
// create two vectors to position the ellipse
SharpDX.Vector2 startPoint = new SharpDX.Vector2(x, y);
SharpDX.Vector2 endPoint = new SharpDX.Vector2(x, y);
// calculate the center point of the ellipse from start/end points
SharpDX.Vector2 centerPoint = (startPoint + endPoint) / 2;
// set the radius of the ellipse
float radiusX = 5;
float radiusY = 5;
// construct the rectangleF struct to describe the position and size the drawing
SharpDX.Direct2D1.Ellipse ellipse = new SharpDX.Direct2D1.Ellipse(centerPoint, radiusX, radiusY);
// define the brush used in the rectangle
SharpDX.Direct2D1.SolidColorBrush customDXBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.DodgerBlue);
// execute the render target fill ellipse with desired values
RenderTarget.FillEllipse(ellipse, customDXBrush);
// always dispose of a brush when finished
customDXBrush.Dispose();
}
}

Comment