For example is index x of second data series part of index 0 of primary dataseries
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Check if second data series exists in primary
Collapse
X
-
Check if second data series exists in primary
So for example, I am adding a second 1 tick data series. I want to be able to check if the index of the second dataseries falls into the current index of the primary data series. Any way to do this?
For example is index x of second data series part of index 0 of primary dataseriesTags: None
-
Hello zextra,
You can use Bars.GetBar() to get a bar index by time.
Below is a public link to the help guide.
This means you can compare the time of the bar of the added series you have selected and find the bar that was open during that time on the primary series.Chelsea B.NinjaTrader Customer Service
-
Hello zextra,
Below is an example of using Bars.GetBar() to match a historical tick with the primary bar that was open when the tick was received.
The code runs after the second to last primary bar has closed. The example gets the time of the tick received 1000 ticks ago. Then using the time of the tick finds the primary bar that was open when that tick was received.
Code:if (CurrentBars[0] < 2 || CurrentBars[1] < 1000 || BarsInProgress != 1 || (State == State.Historical && CurrentBars[0] != Count - 3)) return; int primaryBarNum = BarsArray[0].GetBar(Times[1][1000]); if (primaryBarNum > CurrentBars[0]) Print("Tick belongs to open building bar"); else Print(string.Format("Tick within to {0}", Times[0][CurrentBars[0] - primaryBarNum] ));Chelsea B.NinjaTrader Customer Service
Comment
-
Thank you for the code segment. I am trying to sum up the volume of the ticks from the 1 tick chart so that it equals the actual volume. I have a dataseries called myvolume that I am summing up the volume from the 1 tick chart. After doing this and printing myvolume dataseries, it does not match the actual volume dataseries. What am I doing wrong? Thank you.
if (CurrentBars[0] < 2) return;
if (BarsInProgress != 1) return;
int primaryBarNum = BarsArray[0].GetBar(Times[1][0]);
int mainBar = 0;
if (primaryBarNum <= CurrentBars[0])
mainBar = CurrentBars[0] - primaryBarNum;
myvolume[mainBar] += Volumes[1][0];
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
332 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment