foreach loop problem - NinjaTrader Programming | futures io social day trading
futures io futures trading


foreach loop problem
Updated: Views / Replies:3,214 / 14
Created: by gomad Attachments:4

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • 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.

-- Big Mike, Site Administrator

Reply
 4  
 
Thread Tools Search this Thread
 

foreach loop problem

  #11 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary

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
foreach loop problem-6j-06-11-5-min-17_05_2011.jpg  
Attached Files
Register to download File Type: zip StatsIndicatorFor.zip (2.0 KB, 32 views)
Reply With Quote
The following 3 users say Thank You to Fat Tails for this post:
 
  #12 (permalink)
Elite Member
Tirgu Mures, Romania
 
Futures Experience: Intermediate
Platform: Ninja
Broker/Data: ZenFire
Favorite Futures: CL, GC
 
Posts: 36 since Sep 2010
Thanks: 42 given, 6 received

Thank you


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.

Reply With Quote
 
  #13 (permalink)
Membership Temporarily Revoked
NYC
 
Futures Experience: None
Platform: graph paper and pencil
Favorite Futures: harp
 
dutchbookmaker's Avatar
 
Posts: 187 since Dec 2010
Thanks: 9 given, 107 received



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
The following 2 users say Thank You to dutchbookmaker for this post:
 
  #14 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary


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
The following user says Thank You to Fat Tails for this post:
 
  #15 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,357 given, 83,238 received

Moved to NT Programming.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote

Reply



futures io > > > > > foreach loop problem

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
ZigZagUTC problem lookOutBelow NinjaTrader 7 February 20th, 2013 02:27 PM
OODA Loop and Trading...... tradersam Psychology and Money Management 1 May 18th, 2011 03:36 PM
Translate For Loop in Easy Language to NT C# Crassius NinjaTrader Programming 6 February 23rd, 2011 08:34 AM
could be a problem websouth Off-Topic 11 February 1st, 2010 02:04 PM
Problem with Thanks Given; Thanks Received lolu Feedback and Announcements 2 December 14th, 2009 08:30 AM


All times are GMT -4. The time now is 04:48 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-18 in 0.09 seconds with 20 queries on phoenix via your IP 54.221.136.62