The following indicator I have starts it's calculations on the current bar (0) as opposed to starting w/ the first bar in the chart. Why? If you look at the Heiken Ashi indicator (or any other indicator for that fact) it starts at the far left of the chart. So, why isn't mine? Here's the code: Any ideas would be greatly appreciated
Inserted Code
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int bbPeriod = 10;
extern int bbDeviation = 2;
extern int bbPrice = PRICE_CLOSE;
int windowhandle;
double Bandwidth[];
string windowname;
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
windowname=StringConcatenate("Bandwidth - Period=",bbPeriod);
IndicatorShortName(windowname);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Bandwidth);
SetIndexLabel(0,"Bandwidth");
IndicatorDigits(Digits+1);
SetIndexDrawBegin(0,10);
windowhandle=WindowFind(windowname);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double bbUpper, bbLower, bbMiddle;
//Bar stuff
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
bbUpper=iBands(NULL,0,bbPeriod,bbDeviation,0,bbPrice,MODE_UPPER,pos);
bbLower=iBands(NULL,0,bbPeriod,bbDeviation,0,bbPrice,MODE_LOWER,pos);
bbMiddle=iBands(NULL,0,bbPeriod,bbDeviation,0,bbPrice,0,pos);
Bandwidth[pos]=((bbUpper-bbLower)/bbMiddle)*100;
pos--;
}
return(0);
}