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 sjsj2732, Yesterday, 04:31 AM
|
0 responses
22 views
0 likes
|
Last Post
by sjsj2732
Yesterday, 04:31 AM
|
||
|
Started by NullPointStrategies, 03-13-2026, 05:17 AM
|
0 responses
280 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
279 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
130 views
1 like
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
90 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|

Comment