NexusFi: Find Your Edge


Home Menu

 





Multi Time Frame - Index was outside the bounds of the array


Discussion in NinjaTrader

Updated
    1. trending_up 2,228 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 Jayswiss 
San Francisco, CA / USA
 
Experience: Intermediate
Platform: NinjaTrader, TradingView
Trading: ES, TF, NQ, CL, GC
Posts: 29 since Jun 2016
Thanks Given: 4
Thanks Received: 3

Hi all... I'm new to ninjatrader and I thought I had an understanding of how MTF should work after reading the NT7. Apparently not. My basic attempt at this generates "index was outside the bounds of the array" error.

Here's a sample of the code:

 
Code
 protected override void Initialize()
        {
			Overlay				= false;

			Add(PeriodType.Minute, 3);                                  // 3 min time frame stored at  index[1]  ??

                        double the3minClose        = Closes[1][0];
			Print(the3minClose);

                        double the3minOpen        = Opens[1][0];
			Print(the3minOpen);
        }

Any suggestions here?


(Sorry this should have been posted in NinjaTrader Programming but I don't seem to be able to move it now)


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Double Deadlock: Rubio Calls Hormuz Tolls "Unfeasib …
Traders Hideout
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
Iran and Israel Stand Down: What $9M in Peace Contracts …
Prediction Markets & Event Contracts
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
10 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 
srgtroy's Avatar
 srgtroy 
Los Angeles, California Republic
Legendary  R.I.P. 1965-2023 
 
Experience: None
Platform: Sierra Chart
Broker: CQG
Trading: ES
Posts: 1,928 since Jan 2011
Thanks Given: 1,375
Thanks Received: 3,724


Jayswiss View Post
Hi all... I'm new to ninjatrader and I thought I had an understanding of how MTF should work after reading the NT7. Apparently not. My basic attempt at this generates "index was outside the bounds of the array" error.

Here's a sample of the code:

 
Code
 protected override void Initialize()
        {
			Overlay				= false;

			Add(PeriodType.Minute, 3);                                  // 3 min time frame stored at  index[1]  ??

                        double the3minClose        = Closes[1][0];
			Print(the3minClose);

                        double the3minOpen        = Opens[1][0];
			Print(the3minOpen);
        }

Any suggestions here?


(Sorry this should have been posted in NinjaTrader Programming but I don't seem to be able to move it now)

Not even close, to be honest. Please repost in the appropriate thread and I am sure someone will help you:


Reply With Quote
  #3 (permalink)
 Jayswiss 
San Francisco, CA / USA
 
Experience: Intermediate
Platform: NinjaTrader, TradingView
Trading: ES, TF, NQ, CL, GC
Posts: 29 since Jun 2016
Thanks Given: 4
Thanks Received: 3


Thanks, srgtroy. That's a neat offer from Futures.io

I don't want or need it created for me though. Having something specific to create is what helps motivate me to learn the language.

I already have the indicator fully coded & working on another platform, but I intend to take advantage of some of the more useful features of NinjaTrader (e.g. autotrading, optimization) that the other platform is lacking.

- Jay


Started this thread Reply With Quote
  #4 (permalink)
 
srgtroy's Avatar
 srgtroy 
Los Angeles, California Republic
Legendary  R.I.P. 1965-2023 
 
Experience: None
Platform: Sierra Chart
Broker: CQG
Trading: ES
Posts: 1,928 since Jan 2011
Thanks Given: 1,375
Thanks Received: 3,724

Have you read the whole "NinjaScript" section of the NT7 Help Guide, specifically? That's the first order of business. You may also want to watch this:


@sam028 Where does this thread belong?


Reply With Quote
Thanked by:
  #5 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,759 since Jun 2009
Thanks Given: 3,828
Thanks Received: 4,645

@Jayswiss, you can't access to bars values in Initialize(), this is what generates your error.
Check the genuine SampleMultiTimeFrame strategy, it's a good example, and the NT7 help (NinjaScript > Educational Resources > Tips > Multi-Time Frame & Instruments).


Success requires no deodorant! (Sun Tzu)
Reply With Quote
  #6 (permalink)
 Jayswiss 
San Francisco, CA / USA
 
Experience: Intermediate
Platform: NinjaTrader, TradingView
Trading: ES, TF, NQ, CL, GC
Posts: 29 since Jun 2016
Thanks Given: 4
Thanks Received: 3

Thanks! Yes, I've since realized some of that doesn't belong in initialize section.

Thanks for the tip, I'll check the SampleMultiTimeFrame strategy.


Started this thread Reply With Quote




Last Updated on July 3, 2016


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts