Thanks.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
GetChartCanvasXByTime()
Collapse
X
-
GetChartCanvasXByTime()
How would one get the chart-canvas x-coordinate corresponding to a specified time? Similar to GetXByTime(), but not locked to the slot index of the Bars object.
Thanks.Tags: None
-
Hello zacharydw00,
Can you clarify what you are trying to do? The method GetXByTime is how you get a X coordinate for the charts canvas from a time. The X values you get are based on the slot where the time happened because you are getting the X based on the Time which relates to the bar series being used.
-
Actually what I need is GetTimeByChartCanvasX(). Made a mistake on the subject line.
I'm trying to keep a Draw.Rectangle object at an exact offset location from the chart's canvas left edge or right edge. The D.Rect X location can only be set by startBarsAgo or startTime. Using startTime is the only property that I can see that would allow setting the x-axis by canvas/pixel location.
When the Rect. is positioned on the chart, by me, I can translate the startTime to canvas X coordinate, capturing that canvas edge offset coordinate. As the bars/time progresses throughout the day I want to keep the Rect. at that exact X canvas coordinate. So I need to translate absolute canvas X coordinate to Time and feed that new Time back to the Rect.
The Y location is not a problem, because there are method to do that.Last edited by zacharydw00; 06-23-2023, 11:41 AM.
Comment
-
Hello zacharydw00,
The drawing objects are not intended for that use, you need to draw your own rectangle using OnRender to keep it fixed based on the panel and not bar times.
To keep an item a fixed offset from the edge you just use a fixed X value. You can use ChartPanel.X to know the left of the chart and ChartPanel.W to know how wide the chart is. ChartPanel.X + ChartPanel.W - yourOffsetAmount will give you a fixed position on the right edge. ChartPanel.X + yourOffsetAmount would be for the left edge.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
601 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
347 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
559 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
558 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment