Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Draw line object at an angle
Collapse
X
-
Hello MisterGee,
Attached is an example that can draw to the left edge of the current bar. Please see the OnRender method and the DrawLine method there in where the coordinates are supplied. The example uses some helper methods for SharpDX rendering that could be re-used in other scripts.
Please note that bar coordinates can be retrieved with ChartControl.GetXByBarIndex and ChartScale.GetYByValue.
GetXByBarIndex - https://ninjatrader.com/support/help...bybarindex.htm
GetYByValue - https://ninjatrader.com/support/help...etybyvalue.htm
We look forward to assisting.
-
Thanks for your reply Jim,
I have attempted to integrate your information into my code however being novice has made this difficult! Would you be able to provide a sample code for setting a variable to the X coordinate of the left edge the current bar (most recently painted)?
Thanks
Leave a comment:
-
Hello MisterGee,
ChartControl.Properties.BarDistance can get the distance in pixels between the left/right edge of a bar and ChartControl.GetBarPaintWidth can be used to get the width of each bar in pixels.
ChartControl.Properties - https://ninjatrader.com/support/help...properties.htm
ChartControl.GetBarPaintWidth() - https://ninjatrader.com/support/help...paintwidth.htm
Let us know if there is anything else we can do to help.
Leave a comment:
-
Thank you. What might actually be more helpful to me is knowing, what is the distance between bars on a standard bar width/spacing chart.
I would like to plot points along an angled line below the price/bars but without knowing the x coordinate (how far along the x axis price (each bar) moves) I am unable to find the y coordinate on the line. What is the unit of measure between each bar?
Leave a comment:
-
Hello MisterGee,
Thanks for your question.
Small snippets of sample code for using Drawing methods can be found in the Help Guide.
Drawing - https://ninjatrader.com/support/help...t8/drawing.htm
When drawing a line, we need to provide an X coordinate (a time or a certain number of bars ago from when we draw the line) and a Y coordinate (price level.) Visually, this will not reflect the same angle, because as we adjust the scale of the chart, the angle of the line will change. However, since the line is drawing from the same X and Y coordinates, the slope of that line is the same in relativity to Rise/Run.
If you would like to have code generated that draws a line from 2 different points and are unfamiliar writing the C# code, I suggest using the Strategy Builder to generate syntax to draw a line.
Drawing on a chart - https://ninjatrader.com/support/help...ToDrawOnAChart
For example, the Strategy Builder can be used to generate syntax like the following:
Code:if (CurrentBars[0] < 10) return; Draw.Line(this, @"MyCustomStrategy7 Line_1", true, 10, High[10], 0, High[0], Brushes.CornflowerBlue, DashStyleHelper.Solid, 2);
To get more acquainted with SharpDX rendering, please see the Help Guide article below, and please see the SampleCustomRender indicator that comes with NinjaTrader.
https://ninjatrader.com/support/help..._rendering.htm
We look forward to assisting.
Leave a comment:
-
Draw line object at an angle
Hello,
Is there any sample coding that will automatically draw a line from a specified price point at a specific angle?
ThanksTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by lucasmelo152, 06-28-2021, 12:51 PM
|
8 responses
2,123 views
0 likes
|
Last Post
by Ymcapital
Today, 04:31 PM
|
||
Started by Creamers, 04-27-2024, 05:32 AM
|
11 responses
68 views
0 likes
|
Last Post
by Creamers
Today, 04:30 PM
|
||
Started by NM_eFe, 04-30-2024, 06:14 AM
|
5 responses
30 views
0 likes
|
Last Post
by NM_eFe
Today, 04:28 PM
|
||
Started by Jonker, 04-27-2024, 01:19 PM
|
2 responses
20 views
0 likes
|
Last Post
by Jonker
Today, 04:25 PM
|
||
Started by Max Baxter, 03-07-2019, 09:20 PM
|
8 responses
266 views
0 likes
|
Last Post
by Ymcapital
Today, 04:17 PM
|
Leave a comment: