NexusFi: Find Your Edge


Home Menu

 





foreach loop problem


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one gomad with 6 posts (0 thanks)
    2. looks_two Fat Tails with 5 posts (6 thanks)
    3. looks_3 gulabv with 2 posts (1 thanks)
    4. looks_4 Big Mike with 1 posts (0 thanks)
    1. trending_up 6,705 views
    2. thumb_up 9 thanks given
    3. group 3 followers
    1. forum 14 posts
    2. attach_file 4 attachments




 
Search this Thread

foreach loop problem

  #11 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103

As I answered in post #6, you cannot access negative bars. The first bar of the chart has the index 0. So if you select a period of 13, the index of the current bar should be equal to or greater than 13.

Have modified the indicator, put the variables where they belong and added a property to access the period value.

Attached Thumbnails
Click image for larger version

Name:	6J 06-11 (5 Min) 17_05_2011.jpg
Views:	204
Size:	88.3 KB
ID:	38744  
Attached Files
Elite Membership required to download: StatsIndicatorFor.zip
Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Better Renko Gaps
The Elite Circle
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #12 (permalink)
 gomad 
Tirgu Mures, Romania
 
Experience: Intermediate
Platform: Ninja
Broker: ZenFire
Trading: CL, GC
Posts: 36 since Sep 2010
Thanks Given: 42
Thanks Received: 7


Fat Tails View Post
As I answered in post #6, you cannot access negative bars. The first bar of the chart has the index 0. So if you select a period of 13, the index of the current bar should be equal to or greater than 13.

Have modified the indicator, put the variables where they belong and added a property to access the period value.

Thank you. I didn't understand why that condition is needed in one case (for 13), but not for a lower number. For when I used a lower number, the indicator worked fine.

Started this thread Reply With Quote
  #13 (permalink)
 dutchbookmaker 
NYC
 
Posts: 187 since Dec 2010



gomad View Post
The same problem with the "for loop". It is working now with number 13 or lower, but not with 14 or higher.

Are there some "build in" limitations in NT?

I want to explain now what I want to obtain.


Isn't this because you are creating an array with 13 elements which will be indexed 0-12, so trying to access array[13] is the 14th element of the array that makes no sense.
The ArrayList that Fat Tails mentioned has the advantage of being dynamic as far as element size so you don't have to manually allocate memory at compile time like you do with a regular array.
The limitations for both are how much memory you have.
Print(arraylist.count) is good for debugging, will give you have many elements your arraylist has.

Reply With Quote
  #14 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


gomad View Post
Thank you. I didn't understand why that condition is needed in one case (for 13), but not for a lower number. For when I used a lower number, the indicator worked fine.

Both indicators you posted compiled but could not be applied to any chart, even not for a period of 12. If you look at the code, you will understand that for the first bar of the chart, which has the index 0, you tried to access negative bars, which do not exist. Logically both your indicators threw exceptions and did not plot anything.

Reply With Quote
Thanked by:
  #15 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,463 since Jun 2009
Thanks Given: 33,239
Thanks Received: 101,662

Moved to NT Programming.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on May 17, 2011


© 2024 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 - Privacy Policy - Downloads - Top
no new posts