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:
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 JoMoon2024, Today, 06:56 AM
|
0 responses
6 views
0 likes
|
Last Post
by JoMoon2024
Today, 06:56 AM
|
||
Started by Haiasi, 04-25-2024, 06:53 PM
|
2 responses
17 views
0 likes
|
Last Post
by Massinisa
Today, 05:32 AM
|
||
Started by Creamers, Today, 05:32 AM
|
0 responses
6 views
0 likes
|
Last Post
by Creamers
Today, 05:32 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
12 responses
1,786 views
0 likes
|
Last Post
by Leafcutter
Today, 05:30 AM
|
||
Started by poplagelu, Today, 05:00 AM
|
0 responses
3 views
0 likes
|
Last Post
by poplagelu
Today, 05:00 AM
|
Comment