Why not just define a public Stroke, and use that in your OnRender?
So much simpler than using Brushes and/or handling SharpDX objects.
Plus, Color, Style, and Opacity All end up being user configurable.
public class HTBlank : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = "HTBlank";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
PaintPriceMarkers = false;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
IsSuspendedWhileInactive = true;
MyStroke = new Stroke(System.Windows.Media.Brushes.Red, NinjaTrader.Gui.DashStyleHelper.Dash, 2f, 100);
}
}
protected override void OnBarUpdate() { }
public override void OnRenderTargetChanged()
{
if (RenderTarget != null) MyStroke.RenderTarget = RenderTarget;
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
if(IsInHitTest || RenderTarget == null || ChartPanel == null || MyStroke == null) return;
base.OnRender(chartControl, chartScale);
float y = (ChartPanel.H - ChartPanel.Y) / 2f;
RenderTarget.DrawLine(new SharpDX.Vector2(ChartPanel.X, y), new SharpDX.Vector2(ChartPanel.W, y), MyStroke.BrushDX, MyStroke.Width, MyStroke.StrokeStyle);
}
[Display(Name="MyStoke", Description=@"MyStoke", Order=0, GroupName="Settings")]
public Stroke MyStroke { get; set; }
}
Be Safe in this Crazy World!