For example is index x of second data series part of index 0 of primary dataseries
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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 kempotrader, Today, 08:56 AM
|
0 responses
7 views
0 likes
|
Last Post
by kempotrader
Today, 08:56 AM
|
||
Started by kempotrader, Today, 08:54 AM
|
0 responses
4 views
0 likes
|
Last Post
by kempotrader
Today, 08:54 AM
|
||
Started by mmenigma, Today, 08:54 AM
|
0 responses
2 views
0 likes
|
Last Post
by mmenigma
Today, 08:54 AM
|
||
Started by halgo_boulder, Today, 08:44 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 08:44 AM | ||
Started by drewski1980, Today, 08:24 AM
|
0 responses
4 views
0 likes
|
Last Post
by drewski1980
Today, 08:24 AM
|
Comment