[LegacyColorValue = true]; 

{ TSMEquityDropRatio : Equity Drop Ratio
   Copyright 1999, P. J. Kaufman. All rights reserved. 

	Annualized return divided by the standard deviation of
		the individual drawdowns. Uses only daily data  }

	inputs: equity(numericseries);
	vars: peak(0), draw(0), ndraw(0), tdraw(0), avgdraw(0), 
			sum2(0), stddraw(0), ndays(255);

	if equity > peak then begin
		peak = equity;
		if draw > 0 then begin
			ndraw = ndraw + 1;
			tdraw = tdraw + draw;
			avgdraw = tdraw / ndraw;
			sum2 = sum2 + power(draw - avgdraw, 2);
			stddraw = squareroot(sum2) / ndraw;
			draw = 0;
			end;
		end
	else begin
		if peak - equity > draw then draw = peak - equity;
		end;
	if stddraw > 0 then 
			TSMEquityDropRatio = equity / ndays / stddraw
		else
			TSMEquityDropRatio = 0;
