Details of my use case: I add a 2nd data series (same instrument, primary bars 500-tick, secondary bars 2500-tick) via script, get an SMA value from the secondary data series, and then use RenderTarget.DrawLine for that value. I want to draw the line out into the future covering 5 bars, at which point I will get a new SMA value and therefore a new line. My starting SlotIndex is the 500-tick bar that aligns with the completion of the 2500 tick bar. I add a value to that slot to get the future slot, and that is where I want the line to terminate. Everything else about the script is working fine, except for the endpoint of the line. I would rather the endpoint would be fixed, just as the startpoint is.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
RenderTarget DrawLine future slot
Collapse
X
-
RenderTarget DrawLine future slot
What is the best way to draw a line extending exactly 5 Slots into the future? The best option I have found so far is to GetTimeBySlotIndex, and then to GetXByTime. That is less-than-ideal for my use case, because my results have the end of the line moving. It looks to me like this is due to the variable time stamp associated with future tick bar slots and probably relative refresh rate. I see functions to get SlotIndex by Time or by X, and to get Time by SlotIndex, but nothing to get X by SlotIndex. I can only get X by BarIndex or by Time.
Details of my use case: I add a 2nd data series (same instrument, primary bars 500-tick, secondary bars 2500-tick) via script, get an SMA value from the secondary data series, and then use RenderTarget.DrawLine for that value. I want to draw the line out into the future covering 5 bars, at which point I will get a new SMA value and therefore a new line. My starting SlotIndex is the 500-tick bar that aligns with the completion of the 2500 tick bar. I add a value to that slot to get the future slot, and that is where I want the line to terminate. Everything else about the script is working fine, except for the endpoint of the line. I would rather the endpoint would be fixed, just as the startpoint is.
-
Hello jclup,
Thanks for your post.
I believe you can more easily accomplish your goal by offsetting from the last visible bar.
For example, you could try offsetting your ending X coordinate by (chartControl.Properties.BarDistance * 5) from the last visible bar on the chart. I.E. from chartControl.GetXByBarIndex(ChartBars, BarsArray[0].Count-1);
ChartControl Properties - https://ninjatrader.com/support/help...properties.htm
GetXByBarIndex - https://ninjatrader.com/support/help...bybarindex.htm
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
597 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
343 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
556 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
555 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment