Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
Looking forward to your help in understanding these concepts.
Thanks,
Brendan
Can you help answer these questions from other members on NexusFi?
Forget about the charting / visual component because this will confuse you.
For programming the way the indexing works is like this.
0 = Current Bar
1 = 1 Bar Ago
2 = 2 Bars Ago
etc.
If you try to access High[15] (15 bars ago) for example, and you run this script without first checking if there are at least 15 bars, then you will hit a very vague / unhelpful error message. So you can put some logic in your code to check the count of bars and make sure it is > x before you call x.
Make sense?
Ian
In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.
In the analytical world there is no such thing as art, there is only the science you know and the science you don't know. Characterizing the science you don't know as "art" is a fools game.