Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
RenderTarget.DrawLine question...
Collapse
X
-
RenderTarget.DrawLine question...
In my custom DrawingTool, I've successfully gotten to the point where my startPoint is created on mouse hit, and the endPoint is calculated. What I would like to happen is a line get's drawn automatically. So far, I have to actually move the mouse in order to draw the line (for example). I'm missing something. Do I further look into OnRender()? or is there somewhere else that would make this happen. I understand it's like drawing a Horizontal, or Vertical line, and I've reverse engineered that to give me the points I desire, it's just the auto drawing of the line that eludes me. Any sort of help what be great, thanks.Tags: None
-
Hello funk101,
Thank you for writing in. I created an extremely basic drawing tool to test this. I was able to create a drawing tool which you click once on the chart and it draws a line from the point you clicked to a calculated point elsewhere on the chart. This was accomplished in the OnRender() method. Here is the example:
If you have questions that are specific to your code, please feel free to send in the relevant code you are working with so we can better assist.Code:namespace NinjaTrader.NinjaScript.DrawingTools { public class AutomaticLineTest : DrawingTool { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @""; Name = "AutomaticLineTest"; } } Point point; public override Cursor GetCursor(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, Point point) { return Cursors.Arrow; } public override Point[] GetSelectionPoints(ChartControl chartControl, ChartScale chartScale) { return new Point[0]; } public override void OnMouseDown(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint) { point = dataPoint.GetPoint(chartControl, chartPanel, chartScale); //Get the start point } public override void OnRender(ChartControl chartControl, ChartScale chartScale) { RenderTarget.DrawLine(point.ToVector2(), new Point(point.X + 200, point.Y).ToVector2(), Brushes.Aqua.ToDxBrush(RenderTarget)); //Draw the line from the start point to a new end point } } }
Thank you in advance.Michael M.NinjaTrader Quality Assurance
-
Ok, thanks for your reply. I now am able to select a bar, a startAnchor/startPoint, and endAnchor/endPoint are created at the desired location,and a line auto-draws now, however, if I move my mouse the endAnchor moves still, and the line stays the same(which is ok). It's not until I mouse down again that the start and end anchors disappear and I'm left with the desired line intact.
Comment
-
Hello funk101,
Thank you for the update. To better illustrate this behavior could you please create a quick video or send in the drawing tool code?
You can make a quick video using the free tool provided by TechSmith: https://www.techsmith.com/jing-features.html
If you would like to send in your drawing tool code you can attach it in an email to platformsupport[AT]ninjatrader[DOT]com with the subject line: "ATTN: Michael M http://www.ninjatrader.com/support/forum/showthread.php?t=79106"
Thank you in advance.Michael M.NinjaTrader Quality Assurance
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
672 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 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
577 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment