NT8: DataSeries & Times Help! - NinjaTrader Programming | futures.io
futures.io futures trading


NT8: DataSeries & Times Help!
Started: by kidvic Views / Replies:164 / 4
Last Reply: Attachments:0

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.


You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Reply
 
Thread Tools Search this Thread
 

NT8: DataSeries & Times Help!

  #1 (permalink)
Trading for Fun
Los Angeles, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, ThinkOrSwim
Favorite Futures: Options, Futures
 
Posts: 92 since Mar 2015
Thanks: 13 given, 2 received

NT8: DataSeries & Times Help!

So I'm trying to get data from a secondary dataseries, week, and minutes.
I'm using the primary dataseries as 15 minutes.

The problem occurs when accessing the weekly dataseries, with a barsago value >= 2.......

the log tells me : Error on calling 'OnBarUpdate' method on bar 229: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

However, I have expanded days to load to 100, and infinite on the max bars lookback, so I don't know what's going!
Please help!
I have attached what's working, and what isn't.
 
Code
			else if (State == State.Configure)
			{
				AddDataSeries(BarsPeriodType.Week, 1); 
				AddDataSeries(BarsPeriodType.Minute, 60); 
			}
		}

		protected override void OnBarUpdate()
		{
			if (CurrentBars[0] <= 0 || CurrentBars[1] <= 0 || CurrentBars[2] <= 0) return;
			
			//these 3 work
			Print(Times[0][0]);
			Print(Times[1][0]);
			Print(Times[2][0]);
			
			//these 3 work
			Print(Times[0][1]);
			Print(Times[1][1]);
			Print(Times[2][1]);
			
			//these 2 work
			Print(Times[0][2]);
			Print(Times[2][2]);
			
			//but this one doesn't
			Print(Times[1][2]);
		}

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Market Wizard
Germany
 
Futures Experience: Intermediate
Platform: Other
Favorite Futures: ES, YM, 6E
 
Posts: 2,313 since Feb 2013
Thanks: 3,812 given, 5,507 received
Forum Reputation: Legendary



kidvic View Post
 
Code
			
		
			if (CurrentBars[0] <= 0 || CurrentBars[1] <= 0 || CurrentBars[2] <= 0) return;

The problem is your above check. It doesn't prevent your code from trying to access bars that
yet don't exist at the time of the first non-return. E.g.: You are trying to access 2 weeks back
before your index provides 2 weekly bars back. Your CurrentBars might be >0 but that doesn't
ensure that the weekly index is >=2.

So in order to avoid that rookie fault: Access doesn't only depend on history which provides
the theoretical possibility of reaching the correct state at all. Particularly your logics must make
sure that at the point of access there is a sufficient number of bars.

It is helpful for most beginners to read the NT sections how bars develop, since the logical fault
of your code is really very basic.


Last edited by choke35; October 3rd, 2016 at 07:27 AM.
Reply With Quote
The following user says Thank You to choke35 for this post:
 
  #4 (permalink)
Market Wizard
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 2,959 since Dec 2012
Thanks: 9,557 given, 5,855 received
Forum Reputation: Legendary


kidvic View Post
 
Code
	if (CurrentBars[0] < 3 || CurrentBars[1] < 3 || CurrentBars[2] < 3) return;

Try that instead. i.e. I'm checking for at least 3 bars to exist on all of the 3 data series before I can safely access any of them with subscripts [0], [1] or [2].

As @choke35 said, it's a question of whether the bars exist at all yet, effectively the series get going independently. [NB I am assuming 8 behaves similarly to 7 in this respect.]

Just vary the number of bars checked for, depending on your worst-case subscript. In this case I've set them all the same for simplicity. Since many bars will never be seen on screen the 'tightness' of the check is quite arbitrary really, so long as it is safe.

Cheers

Travel Well
Reply With Quote
The following 2 users say Thank You to ratfink for this post:
 
  #5 (permalink)
Trading for Fun
Los Angeles, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader, ThinkOrSwim
Favorite Futures: Options, Futures
 
Posts: 92 since Mar 2015
Thanks: 13 given, 2 received

Futures Edge on FIO

Which products do you trade?

 

choke35 View Post
The problem is your above check. It doesn't prevent your code from trying to access bars that
yet don't exist at the time of the first non-return. E.g.: You are trying to access 2 weeks back
before your index provides 2 weekly bars back. Your CurrentBars might be >0 but that doesn't
ensure that the weekly index is >=2.

So in order to avoid that rookie fault: Access doesn't only depend on history which provides
the theoretical possibility of reaching the correct state at all. Particularly your logics must make
sure that at the point of access there is a sufficient number of bars.

It is helpful for most beginners to read the NT sections how bars develop, since the logical fault
of your code is really very basic.

Thanks, it worked.

Reply With Quote
The following user says Thank You to kidvic for this post:

Reply



futures.io > > > > > NT8: DataSeries & Times Help!

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

2016 True Edge Awards: Voting is open until Jan 21!

Now
 

Anthony Drager: Pulling the trigger with confidence

Elite only
 

Leo Murphy: The Art and Science of Technical Analysis

Elite only
 

FuturesTrader71: Ask Me Anything

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sody's Point & Figure NT8 SodyTexas The Elite Circle 8 November 8th, 2016 12:55 PM
NT7, NT8- Get Feed of Price Change to Method/Event & Confirm Order ieitani NinjaTrader Programming 8 July 9th, 2016 06:10 AM
NT8 Time & Sales Problem Segwin The Elite Circle 2 June 21st, 2016 02:28 PM
Help with Arrays or DataSeries Shinkarev NinjaTrader Programming 1 February 12th, 2016 09:00 AM
Multiple dataseries Breakout NinjaTrader 28 March 30th, 2015 01:14 PM


All times are GMT -4. The time now is 07:47 PM.

no new posts
Page generated 2017-01-21 in 0.11 seconds with 19 queries on phoenix via your IP 174.129.120.155