I am having some trouble understanding how to correctly have a line rendered on the chart using values that are calculated on OnBarUpdate. Below I have attached a picture that shows two lines. The blue line is rendered in OnRender, and the purple line is a line drawn using DrawLine() in OnBarUpdate. The blue line needs to be rendered where the purple line is. I will provide a quick snippet of what I have written to make this happen.
if (State == State.SetDefaults)
{
Calculate = Calculate.OnBarClose;
DefaultBrush2 = System.Windows.Media.Brushes.DodgerBlue;
}
OnBarUpdate()
{
if (!TrendSwitchUp)
{
CreateUpLineOne = true;
//DrawLine
UpTrendLines = Draw.Line(this, "UpTrendLine" + CurrentBar.ToString(), false, TrendsLastBarsAgo, LastLow, 1, High[1], Brushes.DodgerBlue, DashStyleHelper.Solid, 4);
}
}
OnRender()
{
if (!IsInHitTest)
{
//UpLine Render Targets
SharpDX.Vector2 upStartPoint = new SharpDX.Vector2(ChartPanel.X, ChartPanel.Y);
SharpDX.Vector2 upEndPoint = new SharpDX.Vector2(ChartPanel.X + ChartPanel.W, ChartPanel.Y + ChartPanel.H);
//SharpDX Brush Resource
SharpDX.Direct2D1.Brush defaultBrush2Dx;
defaultBrush2Dx = DefaultBrush2.ToDxBrush(RenderTarget);
if (CreateUpLineOne)
{
//RenderLine
RenderTarget.DrawLine(upStartPoint, upEndPoint, defaultBrush2Dx, 2);​
}
defaultBrush2Dx.Dispose();
}
}
The render targets for the blue line are just copied from the 'SampleCustomRender" indicator that Ninjatrader Provides, I did this to just get something on screen since it is my first time using SharpDx tools. It will be greatly appreciated if I can have a bit of guidance on how to get these render targets working correctly to mimic what the DrawLine() is doing.

Comment