It does put squares on top when loaded but as soon as another bar is painted it disappears what is wrong?
I'm trying to combine this sample code from an indicator.
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
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 * 2;
// construct the rectangleF struct to describe the position and size the drawing
//In order to centralise the rectangle over the bar, xStart-width/2
SharpDX.RectangleF rect = new SharpDX.RectangleF(xStart-width/2, 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);
// if (Bars.GetClose(index)>Bars.GetOpen(index))
if (closeGreaterThanOpen.GetValueAt(index) == true)
{
// 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, 1); //Added WH 6/5/2017
}
// always dispose of a brush when finished
customDXBrush.Dispose();
outlineBrush.Dispose();
}
// Default plotting in base class. Should be left Uncommented if indicators holds at least one plot you want displayed
base.OnRender(chartControl, chartScale);
}

Comment