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,547 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?
No book, only a stair: journaling fills where price move …
Cryptocurrency
My Rant with AMP Futures
Trading Reviews and Vendors
Building a free browser DOM/SMC simulator - need some ad …
Platforms and Indicators
Bitcoin’s 2022 low, 2025 high and 2026 low so far arou …
Cryptocurrency
AI for Traders — Agents, Memory, Tools & Real-Worl …
Elite Quantitative GenAI/LLM
 
  #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 Administrator
 
Posts: 3,779 since Jun 2009
Thanks Given: 3,840
Thanks Received: 4,709

@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