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 SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
27 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
17 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
9 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
10 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
17 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment