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.
The following 3 users say Thank You to Fat Tails for this post:
Isn't this because you are creating an array with 13 elements which will be indexed 0-12, so trying to access array 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.
The following 2 users say Thank You to dutchbookmaker for this post:
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.
The following user says Thank You to Fat Tails for this post:
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.