The OnRender code below to draw a rectangle above every bar is compiling, but the drawing is not being rendered. Any ideas what is wrong with my code? Also, where would I place a condition such as "if (Close[0] > Open[1])".
Thank you.
//Examples for this coding came from NT8 Manual Best Practices > Using DrawObjects vs custom graphics in OnRender(), and SampleCustomRender
// loop through all of the viewable range of the chart
for (int index = ChartBars.FromIndex; index <= ChartBars.ToIndex; index++)
{
// gets the pixel coordinate of the bar index passed to the method - X axis
float xStart = chartControl.GetXByBarIndex(ChartBars, index) ;
// gets the pixel coordinate of the price value passed to the method - Y axis
float yStart = chartScale.GetYByValue(High.GetValueAt(index) + 2*TickSize);
float width = (float) chartControl.BarWidth*4;
// construct the rectangleF struct to describe the position and size the drawing
SharpDX.RectangleF rect = new SharpDX.RectangleF(xStart, yStart, width, width);
// // define the brush used in the rectangle
SharpDX.Direct2D1.SolidColorBrush customDXBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.Blue);
SharpDX.Direct2D1.SolidColorBrush outlineBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.Black);
// The RenderTarget consists of two commands related to Rectangles.
// The FillRectangle() method is used to "Paint" the area of a Rectangle
// execute the render target fill rectangle with desired values
RenderTarget.FillRectangle(rect, customDXBrush);
// and DrawRectangle() is used to "Paint" the outline of a Rectangle
RenderTarget.DrawRectangle(rect, outlineBrush, 2); //Added WH 6/5/2017
// always dispose of a brush when finished
customDXBrush.Dispose();
outlineBrush.Dispose();
}

Comment