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 StockTrader88, 03-06-2021, 08:58 AM
|
45 responses
3,992 views
3 likes
|
Last Post Today, 09:51 AM | ||
Started by TAJTrades, Today, 09:46 AM
|
0 responses
7 views
0 likes
|
Last Post
by TAJTrades
Today, 09:46 AM
|
||
Started by rhyminkevin, Yesterday, 04:58 PM
|
5 responses
62 views
0 likes
|
Last Post
by dp8282
Today, 09:36 AM
|
||
Started by realblubb, Today, 09:28 AM
|
0 responses
8 views
0 likes
|
Last Post
by realblubb
Today, 09:28 AM
|
||
Started by AaronKoRn, Yesterday, 09:49 PM
|
1 response
19 views
0 likes
|
Last Post
by Rikazkhan007
Today, 09:24 AM
|
Comment