Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Help with Custom Render
Collapse
X
-
Help with Custom Render
The attached NinjaScript is attempting to Print() the x position of each bar from inside of OnRender() to confirm I can locate it before doing other things with it. Here is a screenshot of my errors. Thanks for the help. -
Hello swcooke,
Thanks for your post.
Your errors are reporting to line 55. The first error is telling you that GetXByBarIndex has some invalid arguments and the second error reports that a Bars object cannot be converted to a ChartBars object.
To troubleshoot these compiler errors, I recommend looking up these items in the help guide to see the proper syntax. Also, I see that you are creating a ChartBars object "chartBars" that does not have any context. "ChartBars" should be used.
I suggest using the SampleCustomRender indicator as a working example to reference as you are experimenting with custom rendering. It may be useful to clone this example and reduce it to get a better idea on how you can create your own rendering syntax.
- GetXByBarIndex - https://ninjatrader.com/support/help...bybarindex.htm
- ChartBars - https://ninjatrader.com/support/help...?chartbars.htm
- ChartBars.Bars object - https://ninjatrader.com/support/help...tbars_bars.htm
- In depth reference for working with custom rendering can be found here - https://ninjatrader.com/support/help..._rendering.htm
The information linked above is publicly available.
Please let us know if you have any additional questions.
-
Just a suggestion you can try...
Add the following at the start of OnRender():
Remove:Code:if(Bars == null || ChartBars.Bars == null || Bars.Instrument == null || CurrentBar < 1) { return; } base.OnRender(chartControl, chartScale);
And use:Code:ChartBars chartBars;
Hope this helps.Code:for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++) { int x = chartControl.GetXByBarIndex(ChartBars, idx); Print(x); }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
670 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 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
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment