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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
557 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment