Asheville, North Carolina
Posts: 24 since Sep 2010
Thanks Given: 1
Thanks Received: 15
|
You are dealing with poorly written code. BarIndex() returns an array in which the first bar is 0 in contrast to Barcount which is the number of bars (a single number) starting at 1. If this makes no sense, read the section of the Users Guide regarding arrays. So for the last bar BarIndex() = BarCount - 1.
All you need is one line: xBarIndex = LastValue(BarInddex();
You should read the Help and Users Guide for a full description of both and also look at the "Common Errors" section which discusses common errors using them.
In addition to reading Help and User Guide, put this little piece of code in a blank window and it will help you understand the difference as you click on different bars.
xBarIndex= BarIndex();
x= xBarIndex;
xLastValue= LastValue(BarIndex());//LastValue( x );
Title = "xbarindex=" + xbarindex + " x=" + x + " xlastvalue=" + LastValue(x) + " barcount = " + BarCount;
|