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)
It is difficult to find an error, if you just post one line. What is "list"? How many elements has "list"?
NinjaTrader uses 2 variables for the BarsArray[] object.
CurrentBar: The first bar has the index CurrentBar = 0. The last bar in the data base typically has the value CurrentBar = Count -1, if the indicator is set to CalculateOnBarClose = true, the indicator value for the last bar is not plotted, meaning that the last indicator value shown corresponds to CurrentBar = Count -2.
When OnBarUpdate() is executed it starts with CurrentBar = 0, and then makes one iteration for each historical bar. On real-time bars it will make one iteration, if the indicator is set to CalculateOnBarClose = true, otherwise it will make one iteration with every incoming tick.
Count - 1 usually holds the integer equal to the total number of bars of the BarsArray loaded, while CurrentBar steps up with each iteration until it reaches the value Count-2 (CalculateOnBarClose = true) or Count-1 (CalculateOnBarClose = false).