Thanks!!
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
Multiple DataSeries Issue
Collapse
X
-
Multiple DataSeries Issue
HI, can you tell me why this indicator doesn't process the other dataseries when OnBarUpdate is called? It does when it initially gets loaded.
Thanks!!Tags: None
-
You have five data series => the root plus 4 added series.
You have no logic to segregate processing of each series. So as a first step in debugging you should
process each separately.
Here is a snippet from the help file on how to do that.
protected override void OnStateChange()
{
if (State == State.Configure)
{
// Add a 5 minute Bars object: BarsInProgress index = 1
AddDataSeries(BarsPeriodType.Minute, 5);
}
}
protected override void OnBarUpdate()
{
// Check which Bars object is calling the OnBarUpdate() method
if (BarsInProgress == 0)
{
// A value of zero represents the primary Bars which is the ES 09-14
// 1 minute chart.
// Do something within the context of the 1 minute Bars here
}
else if (BarsInProgress == 1)
{
// A value of 1 represents the secondary 5 minute bars added in the Initialize()
// Do something within the context of the 5 minute Bars
}
}
-
Thanks for the reply. I don't have any segregated logic because I want it to perform the same steps for each dataseries. If I add this logic it would be just a lot of duplicated code. Is that thought process wrong?
I tested it and that didn't work. Additionally, this code works fine in a strategy
Thanks!!Last edited by RiversideDude; 04-29-2017, 10:32 AM.
Comment
-
Hello,
Thanks for the post.
Could you provide the output you are getting for the indicator currently?
Additionally, have you removed the indicator from the chart and re-added it after adding the AddDataSeries syntax? In some cases, the series may not have loaded if the instance was not replaced.
Finally, are you able to pull up the secondary instruments with the settings you had used in the script in a chart to see the data?
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Attached is the output that I get when the indicator is initially enabled and after I start the market playback.I did remove and re-add the indicator. Not sure I understand your last question.
Thanks!!Last edited by RiversideDude; 04-29-2017, 10:02 PM.
Comment
-
Good news, it works when the market is "Live". I was testing it during playback, I bet I didn't have the data for the other dataseries downloaded.
Thanks for the help!!
Comment
-
I'm trying to add a variable to count the number of dataseries processed but I can't figure out were to initialize it.
For example: This indicator has 7 dataseries. I want to know once the 7th dataseries has been processed.
Thanks!!Attached Files
Comment
-
-
It didn't work quite as expected since DataLoaded is called only once after all data series have been loaded. What about every time a new bar closes?
Comment
-
-
I did. I also tried State==State.DataLoaded in OnBarUpdate and no luck, it doesn't trigger. It only triggers for the initial load, but not for any bar closes that happens after that.
Thanks!!
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by TheTradingMantis, 10-31-2017, 03:18 PM
|
5 responses
1,250 views
0 likes
|
Last Post
by TheAngryCube
Today, 04:06 PM
|
||
Started by Padan, Today, 02:02 AM
|
9 responses
21 views
0 likes
|
Last Post Today, 03:27 PM | ||
Started by spottysallrite, Today, 11:31 AM
|
7 responses
22 views
0 likes
|
Last Post Today, 03:26 PM | ||
Started by nandhumca, Today, 03:15 PM
|
1 response
4 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by PopovDS, 03-11-2024, 12:49 PM
|
3 responses
17 views
0 likes
|
Last Post
by PopovDS
Today, 03:16 PM
|
Comment