how to get bars array from certain time (ex. ETH open) to right side of my chart? (what I see). But if I'll go to the right new bars will be added to the array. Until new day (ETH open).
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Bars array
Collapse
X
-
Bars array
Hi,
how to get bars array from certain time (ex. ETH open) to right side of my chart? (what I see). But if I'll go to the right new bars will be added to the array. Until new day (ETH open).Tags: None
-
-
Hello Leeroy_Jenkins,
Thank you for that.
You could do what you are asking however there would be some requirements that surround that. Working with data in that way avoids using BarsAgo and instead would use the actual indexes for the bars. Getting the index of the session bar could be tricky, do you mean the session relative to what you are viewing currently or the most recent session?
If you mean relative to what is being viewed you would likely need to use IsFirstBarOfSessionByIndex and a loop backwards to find the session that is before the last visible bar on the chart.
This sample also shows part of what you would need, mainly a loop and the ChartBars.ToIndex. The ToIndex is the last visible bar on the chart and changes as you scroll.
A loop similar to that could be used, a loop from the ToIndex to 0 checking if the bar by index is a session bar. Once you know the start of the session you can use that index for the start point and the ToIndex as the end point. That would span the session begin to the last visible bar.
When working with data in this way keep in mind you won't be able to make a series or pass this to indicators, this would be more if you wanted to do some math calculation based on a set of datapoints.
I look forward to being of further assistance.
- Likes 1
Comment
-
I just need to calculate average range of those bars (between ToIndex and first bar of the session) Is this possible?Originally posted by NinjaTrader_Jesse View PostHello Leeroy_Jenkins,
When working with data in this way keep in mind you won't be able to make a series or pass this to indicators, this would be more if you wanted to do some math calculation based on a set of datapoints.
Comment
-
Comment
-
Hello Leeroy_Jenkins,
Yes however as noted you would have to just use math and the values from the selected range of datapoints that you find. If you loop over a section of data to gather the values that is no longer a series of data that could have indicators or other existing calculations applied. If you wanted to find the average range of those bars you would have to use logic to calculate that value.
If you need to find values from the series you have for that section of time you can use the GetValueAt method for series of the script or indicators:
I look forward to being of further assistance.Last edited by NinjaTrader_Jesse; 03-19-2020, 09:55 AM.
- Likes 1
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
647 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
368 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 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
571 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment