I see ChartBars.Bars, but not sure how to index that (is 0 the main array of bars?) - I'm not new to C# but I'm a NT programming novice.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
From DrawingTools namepace object, get High and Low of a bar that has been clicked on
Collapse
X
-
From DrawingTools namepace object, get High and Low of a bar that has been clicked on
I am trying to get the Bar object when it is clicked on from a drawing tool. I can't seem to find how to reference it. I can get to it from an indicator, but not sure how to get to the array with a DrawingTool. Do you have any examples I could leverage? I did quite a bit of searching and didn't find it.
I see ChartBars.Bars, but not sure how to index that (is 0 the main array of bars?) - I'm not new to C# but I'm a NT programming novice.
Last edited by robbsadler; 06-29-2022, 12:11 PM. -
Hello robbsadler,
Thank you for your post.
You'd need to grab the ChartBars in the OnMouseDown method using GetAttachedToChartBars():
Code:public override void OnMouseDown(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint) { // get the attached chart bars ChartBars myBars = GetAttachedToChartBars(); int MyBarIdx = myBars.GetBarIdxByTime(chartControl, dataPoint.Time); Print("High: " + myBars.Bars.GetHigh(MyBarIdx) + " | Low:" + myBars.Bars.GetLow(MyBarIdx)); // code continues
Please let us know if we may be of further assistance to you.
- Likes 1
-
Thanks for the guidance - it was very helpful!
Now I am trying to go in the opposite direction from an OnBarUpdate event. How do I get the chartScale so I can call chartScale.GetYByValue?
Thanks again!
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
93 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
138 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
68 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
123 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
73 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment