Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Last bar
Collapse
X
-
Hello,
To locate the Last bar, you could use ChartBars.ToIndex.
This would be one example of a way to calculate this:
The mode variable in this example accounts for changing the Calculate mode, this is not necessary if you will be using OnEachTick, for OnBarClose you would need to adjust the count minus 1.Code:int mode = Calculate == Calculate.OnBarClose ? 1 : 0; Print(CurrentBar + " " +(ChartBars.ToIndex - mode));
For a real world use of ChartBars.ToIndex, please see the Misc region in the Pivots indicator.
I look forward to being of further assistance.
-
Hello,
This should handle both tick or price change, the Count would change depending on if you have Intra bar granularity or not.
Using a Print without subtracting the value like shown in the previous example would better highlight the index differences when you toggle the setting.
I look forward to being of further assistance.Code:Print(CurrentBar + " " +ChartBars.ToIndex);
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
67 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
95 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
53 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
108 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
63 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment