I am trying to understand the way ninjatrader uses their bar numbering systems. Methods i.e. High[0] start from the right and move to the left increasing the array count as the bars move to left. However, the current 0 bar is all the way to the left and the current bar numbers increase as the bars move to the right. Please correct me if I have misstated anything so far.
How does that work?
I trade from right to left but the strategies seem to want you to trade from left to right. Let me see if I can explain that better. Trading decisions are made on the hard right side of the chart where new bars are forming or a new bar has just closed. Depending on what your strategy consists of, you may want to "look-back" at some previous time, price, or event to help make a decision on what is happening or has happened as the new bar has formed. I would program from the event that has occurred and look back to a previous price, time, or event and use the array numbering system to identify the event and have plenty of bars on the chart to find that event.
However, (and I may be misunderstanding how the strategies work) it appears to me that the strategies start out at the 0 current bar and there is no way to look past that 0 bar and that is why they require the test for current bars, i.e. there are enough previous current bars closed that your look-back logic doesn't cause an error and stop the script.
1. Is this correct and if not, how do these two numbering systems work and work together?
2. Is there a way to know the total number of bars on the chart so that you don't need to use an arbitrary number of bars in order to condition your look-back logic to not have an index out of range error and to not waste having an exaggerated number of bars just to insure you are safe from the index out of range error.
3. How would you identify the total number of bars on the chart.
Looking forward to your help in understanding these concepts.
Thanks,
Brendan
Comment