Trailing Stop

Looking for code to set a trailing stop based on a specified number of points above or below the high or low of a candle...