Need help with a "spread" indicator

Forex Trader
114538
I am trying to write an Indicator that will record the maximum spread.
However, this wont work.
Of course, I am only interested recording the spread starting at the time when the indicator was attached to the chart... candles before this time would be "null".

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 20
#property indicator_buffers 1
#property indicator_color1 Green


//---- buffers
double Spread[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
	//---- indicators
	SetIndexBuffer(0,Spread);

	SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);

	string short_name = "Spread";
	IndicatorShortName(short_name);
	return(1);
}

double spread;
int start() {
	spread = (Ask - Bid) / Point;
	if (spread > Spread[0]) {
		Spread[0] = spread;
	}

	return(0);
}
//+------------------------------------------------------------------+
Forex Trader
114538
Forex Trader  
I managed to solve the problem:

int start() {
	int counted_bars=IndicatorCounted();

	if (counted_bars >0) counted_bars--;
	int limit=Bars-counted_bars;

	spread = (Ask - Bid) / Point;
	

	for (int i=0; i<limit-1; i++) {
		Spread[i] = MathMax(Spread[i], spread);
	}
	return(0);
}