private Stroke myStroke;
if (State == State.SetDefaults)
{
myStroke = new Stroke(Brushes.Blue, my_DashStyleHelper, 1);
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
Dash_Stroke.RenderTarget = RenderTarget;
RenderTarget.DrawLine(startPoint , endPoint, my_BrushDx, 5, myStroke.StrokeStyle);
}
public override void OnRenderTargetChanged()
{
if (my_BrushDx!= null) { my_BrushDx.Dispose(); }
if (RenderTarget != null)
{
try
{
my_BrushDx = my_Brush.ToDxBrush(RenderTarget);
}
catch (Exception e ) { }
}
[Display(Name = "my_DashStyleHelper")]
public DashStyleHelper my_DashStyleHelper { get; set; }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
OnRender DashStyle
Collapse
X
-
OnRender DashStyle
Is this a correct way to change DashStyle in OnRender?
Code:Last edited by Marty125; 01-06-2025, 11:30 AM.Tags: None
-
Hello Marty125,
That could looks like it would work fine, as it's using the <Stroke>.StrokeStyle as the StrokeStyle parameter.
Are you finding this is not working as expected?
You could specify a new SharpDX.Direct2D1.StrokeStyle object.
RenderTarget.DrawLine(Vector2 point0, Vector2 point1, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
Chelsea B.NinjaTrader Customer Service
-
I am rendering multiple rectangles with RenderTarget.DrawRectangle() and I am experiencing worse performance when using StrokeStyle set to Dash, is it normal? That a few rectangle outlines with dash StrokeStyle are making BIG impact on performance? Or should I try to use SharpDX.Direct2D1.StrokeStyle instead? Thanks
Comment
-
Hello Marty125,
Unfortunately, I wouldn't be an expert in how much time DirectX renders a dashed line on graphic hardware.
Are you finding this is slower than when using an instantiated SharpDX.Direct2D1.StrokeStyle saved to a variable?
I would imagine that a dashed line would require more calculations than a solid line.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
150 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
303 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
243 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
345 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
174 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|

Comment