Reference points to Stroke class but it is not a recognized class. Under NT7 I used DashStyle to draw dashed lines.
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
How to Draw dashed line NT 8
Collapse
X
-
How to Draw dashed line NT 8
I want to draw dashed lines using but cannot find a working example.
Reference points to Stroke class but it is not a recognized class. Under NT7 I used DashStyle to draw dashed lines.Tags: None
-
Hello afshinmoshrefi,
When using Draw.Line(), a DashStyleHelper can be used.
For example:
Code:Draw.Line(this, "lineTag", true, 10, Low[10] - 3 * TickSize, 0, High[0] + 3 * TickSize, Brushes.Blue, [B]DashStyleHelper.Dash[/B], 2);
Chelsea B.NinjaTrader Customer Service
-
I need to use : RenderTarget.DrawLine
I need to use RenderTarget.DrawLine
This is the format in the docs :
RenderTarget.DrawLine(Vector2 point0, Vector2 point1, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
However StrokeStyle isn't a recognized class.
The example below copied from the documents is incomplete and does not work:
Vector2 point0 = new Vector2();
Vector2 point1 = new Vector2();
point0.X = point0X;
point0.Y = point0Y;
point1.X = point1X;
point1.Y = point1Y;
RenderTarget.DrawLine(point0, point1, Stroke.BrushDX, Stroke.Width, Stroke.StrokeStyle);
Comment
-
Hello afshinmoshrefi,
It appears you are trying to get values from a type and not from an object.
Stroke is a type.
Try making a new stroke object and getting the values from that.
Code:Stroke aStroke = new Stroke(Brushes.Blue, DashStyleHelper.Dash, 2); RenderTarget.DrawLine(point0, point1, aStroke.BrushDX, aStroke.Width, aStroke.StrokeStyle);
Chelsea B.NinjaTrader Customer Service
Comment
-
getting memory corruption error
Just tried your lines inside OnRender in a test indicator - attached
SharpDX.Vector2 pp1 = new SharpDX.Vector2(0, chartScale.GetYByValue(2135));
SharpDX.Vector2 pp2 = new SharpDX.Vector2(1300, chartScale.GetYByValue(2135));
Stroke aStroke = new Stroke(Brushes.Blue, DashStyleHelper.Dash, 2);
RenderTarget.DrawLine(pp1, pp2, aStroke.BrushDX, aStroke.Width, aStroke.StrokeStyle);
It compiles but gets the following run time error:
Visual Studio shows the following :
An exception of type 'System.AccessViolationException' occurred in SharpDX.Direct2D1.dll but was not handled in user code
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.Attached Files
Comment
-
Originally posted by afshinmoshrefi View PostJust tried your lines inside OnRender in a test indicator - attached
SharpDX.Vector2 pp1 = new SharpDX.Vector2(0, chartScale.GetYByValue(2135));
SharpDX.Vector2 pp2 = new SharpDX.Vector2(1300, chartScale.GetYByValue(2135));
Stroke aStroke = new Stroke(Brushes.Blue, DashStyleHelper.Dash, 2);
RenderTarget.DrawLine(pp1, pp2, aStroke.BrushDX, aStroke.Width, aStroke.StrokeStyle);
It compiles but gets the following run time error:
Visual Studio shows the following :
An exception of type 'System.AccessViolationException' occurred in SharpDX.Direct2D1.dll but was not handled in user code
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Code:Stroke aStroke = new Stroke(Brushes.Blue, DashStyleHelper.Dash, 2); aStroke.RenderTarget = RenderTarget; RenderTarget.DrawLine(pp1, pp2, aStroke.BrushDX, aStroke.Width, aStroke.StrokeStyle);
Last edited by NinjaTrader_Matthew; 11-15-2016, 03:45 PM.MatthewNinjaTrader Product Management
Comment
-
It worked
Thank you. That worked.
Is creating Stroke object the only way to draw a dashed line using RenderTarget.DrawLine?
Comment
-
Originally posted by afshinmoshrefi View PostThank you. That worked.
Is creating Stroke object the only way to draw a dashed line using RenderTarget.DrawLine?
You can use your own Direct2D1.StrokeStyle
Attached is an example of creating a custom sharpdx StrokeStyle object using a StrokeStyleProperties struct.Attached FilesMatthewNinjaTrader Product Management
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by proptradingshop, 03-21-2024, 09:50 AM
|
5 responses
25 views
0 likes
|
Last Post Today, 05:17 AM | ||
Started by MaupinFinche, Today, 05:08 AM
|
0 responses
2 views
0 likes
|
Last Post
by MaupinFinche
Today, 05:08 AM
|
||
Started by Enkidu, Yesterday, 06:40 AM
|
9 responses
35 views
0 likes
|
Last Post
by Enkidu
Yesterday, 01:11 PM
|
||
Started by Mestor, 03-10-2023, 01:50 AM
|
12 responses
307 views
0 likes
|
Last Post
by z.franck
Today, 04:29 AM
|
||
Started by AgriTrdr, 07-16-2023, 12:54 PM
|
32 responses
268 views
0 likes
|
Last Post
by f.saeidi
Yesterday, 06:49 AM
|
Comment